Rank Diminishing in Deep Neural Networks
Abstract
The rank of neural networks measures information flowing across layers.
It is an instance of a key structural condition that applies across broad domains of machine learning.
In particular, the assumption of low-rank feature representations leads to algorithmic developments in many architectures.
For neural networks, however, the intrinsic mechanism that yields low-rank structures remains vague and unclear.
To fill this gap, we perform a rigorous study on the behavior of network rank, focusing particularly on the notion of rank deficiency.
We theoretically establish a universal monotonic decreasing property of network rank from the basic rules of differential and algebraic composition, and uncover rank deficiency of network blocks and deep function couplings.
By virtue of our numerical tools, we provide the first empirical analysis of the per-layer behavior of network rank in practical settings, i .
e ., ResNets, deep MLPs, and Transformers on ImageNet.
These empirical results are in direct accord with our theory.
Furthermore, we reveal a novel phenomenon of independence deficit caused by the rank deficiency of deep networks, where classification confidence of a given category can be linearly decided by the confidence of a handful of other categories.
The theoretical results of this work, together with the empirical findings, may advance understanding of the inherent principles of deep neural networks.
Introduction
In mathematics, the rank of a smooth function measures the volume of independent information captured by the function [25].
Deep neural networks are highly smooth functions, thus the rank of a network has long been an essential concept in machine learning that underlies many tasks such as information compression [55, 65, 40, 63, 56], network pruning [35, 64, 6, 29, 10], data mining [7, 28, 11, 66, 21, 32], computer vision [68, 67, 34, 30, 32, 70, 69, 17, 18], and natural language processing [9, 31, 8, 12].
Numerous methods are either designed to utilize the mathematical property of network ranks, or are derived from an assumption that low-rank structures are to be preferred.
Yet a rigorous investigation to the behavior of rank of general networks, combining both theoretical and empirical arguments, is still absent in current research, weakening our confidence in the being able to predict performance.
To the best of our knowledge, there are only a few previous works discussing the rank behavior of specific network architectures, like attention blocks [15] and BatchNorms [13, 5] in pure MLP structures.
The empirical validation of those methods are also limited to shallow networks, specific architectures, or merely the final layers of deep networks, leaving the global behavior of general deep neural networks mysterious due to prohibitive space-time complexity for measuring them.
Rigorous work on network rank that combines both strong theoretical and empirical evidence would have significant implications.
In this paper, we make several contributions towards this challenging goal.
We find that the two essential ingredients of deep learning, the chain rules of differential operators and matrix multiplications, are enough to establish a universal principle—that network rank decreases monotonically with the depth of networks.
Two factors further enhance the speed of decreasing: a) the explicit rank deficiency of many frequently used network modules, and b) an intrinsic potential of spectrum centralization enforced by the nature of coupling of massive composite functions.
To empirically validate our theory, we design numerical tools to efficiently and economically examine the rank behavior of deep neural networks.
This is a non-trivial task, as rank is very sensitive to noise and perturbation, and computing ranks of large networks is computationally prohibitive in time and space.
Finally, we uncover an interesting phenomenon of independence deficit in multi-class classification networks.
We find that many classes do not have their own unique representations in the classification network, and some highly irrelevant classes can decide the outputs of others.
This independence deficit can significantly deteriorate the performance of networks in generalized data domains where each class demands a unique representation.
In conclusion, the results of this work, together with the numerical tools we invent, may advance understanding of intrinsic properties of deep neural networks, and provide foundations for a broad study of low-dimensional structures in machine learning.
Preliminaries
Settings We consider the general deep neural network with L layers.
It is a smooth vector-valued function F : R n → R d , where R n and R d are the ambient space of inputs and outputs, respectively.
Deep neural networks are coupling of multiple layers, thus we write F as
[Equation]
For simplicity, we further write the k -th sub-network 2 of F as
[Equation]
and we use F k = F k ( X ) to denote the feature space of the k -th sub-network on the data domain X .
We are more interested in the behavior of network rank in the feature spaces rather than scalar outputs (which trivially have rank 1).
Thus, for classification or regression networks that output a scalar value, we will consider F = F L as the transformation from the input space to the final feature space instead.
Thus, we always have n ≫ 1 and d ≫ 1 .
For example, for ResNet-50 [23] architecture on ImageNet, we only consider the network slice from the inputs to the last feature layer with 2,048 units.
Rank of Function
The rank of a function f = ( f 1 , ..., f d ) T : R n → R d refers to the highest rank of its Jacobian matrix J f over its input domain X , which is defined as
[Equation]
It is well-known that the region of non-highest rank is a zero-measure set on the feature manifold by Sard’s theorem [25], so we are safe to ignore them in the definition of the function ranks.
The rank of a function represents the volume of information captured by it in the output [25].
That is why it is so important to investigate the behavior of neural networks and many practical applications.
Theoretically, by the rank theorem and Sard’s theorem of manifolds [25], we can know that rank of the function equals the intrinsic dimension of its output feature space, as in the following lemma.
Lemma 1.
Suppose that f : R n → R d is smooth almost everywhere.
Let Rank( f )
=
r .
If data domain X is a manifold embedded in R n and ϕ : U → O is a smooth bijective parameterization from an open subset U ⊂ R s to O ⊂ X , then we have dim( f ( X ))
=
Rank( J f ◦ ϕ ) ≤ r .
Thus, the rank of function f gives an upper bound for the intrinsic dimension dim( f ( X )) of the output space.
It is worth mentioning that the intrinsic dimension dim( f ( X )) of the feature space is usually hard to measure, so the rank of the network gives an operational estimate of it.
Numerical Tools
Validating the rank behavior of deep neural networks is a challenging task because it involves operations of high complexity on large-scale non-sparse matrices, which is infeasible both in time and space.
Computing the full Jacobian representation of sub-networks of ResNet-50, for example, consumes over 150G GPU memory and several days at a single input point.
In accuracy, this is even more challenging as rank is very sensitive to small perturbations.
The numerical accuracy of float32 , 1 . 19 e − 7 [45], cannot be trivially neglected in computing matrix ranks.
Thus, in this section we establish some numerical tools for validating our subsequent arguments, and provide rigorous theoretical support for them.
3.1 Numerical Rank: Stable Alternative to Rank
The rank of large matrices is known to be unstable: it varies significantly under even small noise perturbations [48].
Matrices perturbed by even small Gaussian noises are almost surely of full rank, regardless of the true rank of the original matrix.
Thus in practice we have to use an alternative: we count the number of singular values larger than some given threshold ϵ as the numerical rank of the matrix.
Let W ∈ R n × d be a given matrix.
Its numerical rank with tolerance ϵ is
[Equation]
where ∥ W ∥ 2 is the ℓ 2 norm (spectral norm) of matrix W , σ i , i = 1 , ..., min { n, d } are its singular values, and # is the counting measurement for finite sets.
We can prove that the numerical rank is stable under small perturbations.
Based on Weyl inequalities [57], we have the following theorem.
Theorem 1.
For any given matrix W , almost every tolerance ϵ > 0 , and any perturbation matrix D , there exists a positive constant δ max ( ϵ ) such that ∀ δ ∈ [0 , δ max ( ϵ )) ,
Rank ϵ ( W + δ D )
=
Rank ϵ ( W ) .
If W is a low-rank matrix without random perturbations, then there is a ϵ max such that for any ϵ < ϵ max , Rank ϵ ( W + δ D
=
Rank ϵ ( W ) =
Rank( W ) for all δ ∈ [0 , δ max ( ϵ )) .
This property of the numerical rank metric makes it a suitable tool for investigating the rank behavior of neural networks.
Possible small noises can be filtered out in Jacobian matrices of networks by using numerical rank.
It is worth mentioning that random matrices no longer have full rank almost surely under the numerical rank.
Instead their rank distribution can be inferred from the well-known
Marcenko–Pastur distribution [38] of random matrices.
So under numerical rank, low-rank matrices will be commonly seen.
In this paper, we always use the numerical rank when measuring ranks.
3.2 Partial Rank of the Jacobian: Estimating Lower Bound of Lost Rank in Deep Networks
To enable the validation of trend of the network ranks, we propose to compute only the rank of sub-matrices of the Jacobian as an alternative.
Those sub-matrices are also the Jacobian matrices with respect to a fixed small patch of inputs.
Rigorously, given a function f and its Jacobian J f , we denote partial rank of the Jacobian as the rank of a sub-matrix of the Jacobian that consists of the j 1 -th, j 2 -th,..., j K -th column of the original Jacobian
[Equation]
where 1 ≤ j 1 < . . .
< j K ≤ n.
The partial rank can be efficiently computed and the variance of partial ranks of adjacent sub-networks gives a lower bound on the variance of their ranks.
We demonstrate this in appendix F.
3.3 Classification Dimension: Estimating Final Feature Dimension
Measuring the intrinsic dimension of feature manifolds is known to be intractable.
So we turn to an approximation procedure.
For most classification networks, a linear regression over the final feature manifold decides the final network prediction and accuracy.
So we can estimate the intrinsic dimension as the minimum number of principal components in the final feature space to preserve a high classification accuracy.
Let cls : R d → R c be the classification predictions based on the final feature representation F ( x ) , Pro k be the operator that project a vector to the subspace spanned by the top- k PCA components of the final feature representations, and 1 cond the indicator for condition cond .
The classification dimension is then defined as
[Equation]
Networks
ResNetResNet-
GluMixerResMLP-S
Swin-T
ViT-T
ClsDim
Ambient Dim. which is the minimum dimensionality needed to reconstruct the classification accuracy of the whole model.
Simple Principle of Rank Diminishing for General Networks
The specific designs of neural networks are vast and diverse, but most of them share two fundamental ingredients of deep networks, i .
e ., the chain rule and matrix multiplication .
This provides us a chance to analyze the behavior of deep networks that is architecture-agnostic.
So in the theoretical aspect, we will focus on how these two intrinsic structures endow impetus of rank diminishing to neural networks.
A most straightforward observation comes from the basic rule of matrix multiplication that for any two matrices A and B , we have Rank( AB ) ≤ min { Rank( A ) , Rank( B ) } [26].
Taking this into the chain rule of differential of J F = J f L J f L − 1 ...
J f 1 , we then have Rank( J F k ) =
Rank( J f k ◦ F k − 1 ) =
Rank( J f k J F k − 1 ) ≤ Rank( J F k − 1 ) , k = 2 , ..., L, which is Eq.
We can then get the following principle of rank diminishing.
Theorem 2 (Principle of Rank Diminishing) .
Suppose that each layer f i , i = 1 , ..., L of network F is almost everywhere smooth 4 and data domain X is a manifold, then both the rank of sub-networks and intrinsic dimension of feature manifolds decrease monotonically by depth:
[Equation]
This principle describes the behavior of generic neural networks with almost everywhere smooth components, which exhibits the monotonic decreasing (but not strictly) of network ranks and intrinsic dimensionality of feature manifolds.
A flaw of the above principle is that it does not tell whether the rank must decrease.
So we need further analysis for the chance of strictly decreasing.
A most direct reason to support the strictly decreasing comes from the structural impetus of rank deficiency of numerous network components.
Frequently used operations like pooling, downsampling, and dense layer can loose ranks considerably as they explicitly decrease the ambient dimensions of feature representations, or have low rank weight matrices [39].
Specifically, we can have a global criterion for whether a network component will lose ranks as follows.
Theorem 3 (Structural Impetus of Strictly Decreasing) .
5 Roughly speaking, if almost everywhere on the input feature manifold, there is a direction such that moving along this direction keeps the output invariant, then the intrinsic dimension of the output feature manifold will be strictly lower than that of the input.
The maximum number of independent such directions gives a lower bound on the number of lost intrinsic dimensions.
For example, the ReLU activation gives the same output for all inputs that only differs from each other in the negative parts.
Thus the feature manifold after a ReLu activation will lose the dimension for those negative parts.
For general linear layers ( e.g., pure convolution and dense layers), the feature dimensions that belong to the orthogonal complementary spaces of the weights will be lost after applying the linear transformations, as the weight matrices are inactive to changes in their orthogonal complementary spaces.
[Figure]
a
[Figure]
t
i
[Figure] [Figure]
eigenvectors (principal components) of the final feature manifolds.
For all networks a small percentage (see Tab. 1) of eigenvectors is enough to reproduce the classification accuracy of the whole network, indicating a low intrinsic dimension of final feature manifolds.
Note that the x -axes are non-linear.
Limiting Behavior of Network Ranks for Infinitely Deep Networks
From a theoretical perspective, it is of great interest to consider the limiting behavior—the rank of infinitely deep neural networks.
However, it is infeasible to directly consider this problem and give any rigorous analysis for general cases— it is impossible to exhaust the tedious discussion of how specific structures can influence network ranks.
Thus we need to concentrate on a simplified but still representative math model of this problem.
Theory Setup and Its Necessity In brief, we will assume in this section that the Jacobi matrices are random matrices independently following some distributions in a fixed Euclidean space.
We then consider the limiting behavior of the singular values of series { J F n } ∞ n =1 .
Modeling the Jacobi matrices with random matrices allows us to neglect the influence of specific architectures and reveal the intrinsic property using large number law of probability.
While limiting them in the same space is a common practice in analyzing infinitely deep networks [50, 42, 46, 3, 36], as it offers the feasibility to define limits of variables.
For example, if the sizes of Jacobi matrices change from time to time,
[Figure]
some singular values may suddenly disappear or appear in the series { J F n } ∞ n =1 , thus it is unable to define limits for them.
After this simplification
[Figure]
the problem is still representative for understanding what happens in reality.
The transformer, recurrent neural networks
[Figure]
and some very deep CNN architectures with constant width [61] can be viewed as examples of this setting.
Another interesting setting is to assume that
the
Jacobi matrices follow the most simple distribution—Gaussian distributions.
This can lead to a much stronger yet intuitive result on network ranks.
So we are most interested in the limiting behavior when the Jacobi matrices follow weak regularized distributions and the Gaussian distributions.
These two cases then lead to Theorems 4 and 5 correspondingly.
Theorem 4.
Let the network be F = f L ◦ · · · ◦ f 1 , and all the ambient dimensions of feature manifolds be the same as the ambient dimension of inputs, i.e., f k : R n → R n , k = 1 , . . .
, L .
Suppose the Jacobian matrix of each layer f
i independently follows some distribution µ , and E µ [max { log ∥ J ± 1 f k ∥ 2 , 0 } ] < ∞ .
Let σ k denote the k -th largest singular value of J F .
Then there is an integer r < n and positive constants µ r , . . .
, µ n that only depend on µ such that we have for µ -almost everywhere,
[Equation]
meaning that for any tolerance ϵ > 0 , Rank ϵ ( F ) drops below r + 1 as L → ∞ .
Theorem 5.
Let the network be F = f L ◦ ... ◦ f 1 , and all the ambient dimensions of feature manifolds be the same as the ambient dimension of inputs, i.e., f k : R n → R n , k = 1 , ..., L .
Suppose that J f i independently follows the standard Gaussian distribution.
Let σ k denote the k -th largest singular value of J F .
Then almost surely
[Equation]
where ψ = Γ / Γ ′ and Γ is the Gamma function.
That means for a large L and any tolerance ϵ ,
Rank ϵ ( F ) drops to 1 exponentially with speed nC L , where C < 1 is a positive constant that only depends on n .
The proofs of these two theorems rely on the advances of random matrix theory, especially the study of Lyapunov exponents of linear co-cycle systems [51, 59, 19, 47, 33] (see appendix A for detail).
Both of the two theorems reveal that infinitely deep networks have an intrinsic intention to drop ranks rapidly and centralize energy in the largest singular vectors.
This intention is purely aroused by the two essential ingredients, chain rule and matrix multiplication, as here we omit the consideration of specific network designs, but focus on the large number law of coupling of massive smooth functions.
These two theorems point out that the ratio of non-largest singular value divided by the largest one will converge to zero with an exponential speed.
As a result, the numerical rank of the network will decrease quickly after the layer is deep enough.
While this is not the hard rank we use in Theorem 2, we can still use it to infer the low rank structure of feature representations.
Let q 1 , · · · , q n be the singular vectors of J F corresponding to the singular values in Theorem 4, and α i = ⟨ ∆ x / ∥ ∆ x ∥ 2 , q i ⟩ , then when the depth L → ∞ and ∆ x is small, we have F ( x +∆ x ) =
F ( x )+ J F ∆ x + o ( ∥ ∆ x ∥ 2 ) =
σ 1 (cid:80) ri
=
α i q i + σ 1 (cid:80) nj
=
σ j σ 1 α j q j + o ( ∥ ∆ x ∥ 2 ) ≈ σ 1 (cid:80) ri
=
α i q i , which means the neighborhood of data x is mapped into an r -dimensional subspace spanned by the singular vectors of the largest singular values.
This can also explain why layer-wise regularization techniques are helpful for training deep networks, as those regularization techniques re-normalize the singular value distributions of deep networks, easing the trend of the ratio σ i σ 1 becoming infinitesimal.
Specifically, if the data distribution near x is assumed to be standard Gaussian, then the feature distribution is N ( F ( x ) , J T F J F ) , which has a very low rank covariance matrix due to σ i σ 1 , i ≥ r is tiny.
Then applying Batch Normalization will try to pull this feature distribution back to Gaussian with identity covariance, thus ease the trend of feature dimension collapse.
This has also been discussed in related work of the Batch Normalization [13, 5].
We will discuss some other techniques to remiss the rank diminishing in the Appendix.
These two theorems are also connected with the famous gradient explosion issue of deep neural networks [4, 44], where the largest singular value of the Jacobian matrix tends to infinity when the layer gets deeper.
This issue could be viewed as a special case of Theorem 5 that investigates the behavior of all singular values of deep neural networks.
The behavior of network ranks in fact manipulates the well-known gradient explosion issue.
Rigorously, we have the following conclusion.
Corollary 1.
Under the condition of Theorem 5, then almost surely gradient explosion happens at an exponential speed, i.e., log ∥ J F ∥ 2 = log σ 1 ∼ L 2 (log 2 + ψ ( n/ 2))
→ ∞ when L is large.
Validating the Rank Behavior 6.1 Validating Rank Diminishing by Depth
In this section, we numerically validate our theory in three types of architectures of benchmark deep neural networks, CNNs, MLPs, and Transformers, in the ImageNet [14] data domain.
Information of those networks is listed in Tab. A2.
For validating the tendency of network rank of Jacobian matrices, we use the numerical rank of sub-matrices of Jacobian on the central 16 × 16 × 3 image patch of input images.
We report the results of other choices of patches in the Appendix.
Details of the experiment setup can be found in appendix E.
Rank Diminishing of Jacobians As is discussed in Sec.
3.2 and Lemma 2, the partial rank of the
Jacobian is a powerful weapon for us to detect the behavior of huge Jacobian matrices, which are infeasible to compute in practice.
The decent value of partial ranks of adjacent sub-networks provides a lower bound to that of full ranks of them.
Fig.
1 (a,b,c) report the partial rank of Jacobian matrices of three types of architectures, where we can find consistent diminishing of partial ranks in each layer, indicating a larger rank losing for the full rank of Jacobian matrices.
Implicit Impetus Theorem 5 gives an exponential speed of rank decent by layers.
We find that it corresponds well with practice.
We investigate this exponential law in a toy network of MLP-50, which is composed of 50 dense layers, each with 1,000 hidden units.
The MLP-50 network takes
Gaussian noise vectors of R 1000 as inputs, and returns a prediction of 1,000 categories.
As all the feature manifolds are linear subspaces in this case, their intrinsic dimensions can be directly measured by the numerical rank of their covariance matrices.
We report the full rank of Jacobian matrices and intrinsic dimensions of feature manifolds under three different randomly chosen weights in
Fig.
1 (d,e,f).
Due to the digital accuracy of float32 , we stop calculation in each setting when the absolute values of elements of the matrices are lower than 1 .
19 e − 7 .
We can find standard curves of exponential laws in all cases for both ranks of Jacobian and intrinsic dimensions of features.
Structural Impetus We validate the structural impetus in Fig.
To give an estimation for general cases, here we use Gaussian noises with the size of 128 × 8 × 8 as inputs, and randomize weights of the network components to be validated.
We plug those components into a simple fully-connected (FC) layer of 8,192 hidden units.
As the structure is simple, we directly measure the intrinsic dimension of feature spaces and the full rank of Jacobian matrices before and after the features pass the network components to be measured.
The dimension is determined by the number of PCA eigenvalues [27, 58] larger than 1 .
19 e − 7 × N × σ max , where N is the number of PCA eigenvalues, and σ max is the
[Figure]
, to predict the label is reported in blue (if tested on positive samples only, the accuracy rates are 98%, 90%, 82% for cases in (b,c,d) correspondingly).
For comparison, the original accuracy for the corresponding categories are reported in green .
We can find that 1) a few other categories can decide the confidence of the target category i ; 2) some very irrelevant categories contribute the largest weights.
For example in (c), the logits of class ‘junco’ is the negative of ‘triumphal arch’.
Both of them indicate a rather drastic competition of different categories for independent representations in final features due to the tight rank budgets.
largest PCA eigenvalue.
The batch size is set to 5,000.
We find that the convolution (the kernel size is 3 × 3 ) and FC layers (the weight size is 8,192) tend to lose rank considerably, while different normalization layers also lose rank modestly.
But none of them can preserve rank invariant.
6.2 Validating Low-Rank Terminal Spaces
This section seeks evidence to support a low-rank terminal feature space of deep networks, which can then support the significant diminishing of ranks in the previous layers.
The evidence is consisted of a numerical validation that investigates the classification dimension of the terminal feature layer, together with a semantic validation that reveals the independence deficit of deep networks.
Numerical Validation To get an estimation of how many dimensions remain in the final feature representation, we measure the classification dimension in Fig.
2 and Tab.
We report the classification accuracy produced by projecting final feature representations to its top k % eigenvectors in Fig.
We choose a threshold of ϵ such that this procedure can reproduce 95% of the original accuracy of the network.
The corresponding ClsDim is reported in Tab. 1.
As discussed in Sec. 3.3, this gives an estimation of the intrinsic dimension of the final feature manifold.
We can find a universal low-rank structure for all types of networks.
Semantic Validation We want to show that there are only a few independent representations to decide the classification scores for all the 1,000 categories of ImageNet.
Specifically, can we predict the outputs of the network for some categories based on the outputs for a few other categories, as illustrated in Fig.
4 (a)?
And if we can, will those categories be strongly connected to each other?
A surprising fact is that, we can find many counter examples of irrelevant categories dominating the network outputs for given categories regarding various network architectures.
This interesting phenomenon indicates a rather drastic competing in the final feature layer for the tight rank budgets of all categories, which yields non-realistic dependencies of different categories.
To find the dependencies of categories in final features, we can solve the following Lasso problem [52],
[Equation]
(11) where F ( x ) ∈ R 1000 is the slice of network from inputs to the final feature representation, x is the sample from ImageNet X , and W is the final dense layer.
The solution λ ∗ will be a sparse vector, with k non-zero elements λ i 1 ≥ λ i 2 ≥ ...
≥ λ i k , k ≪ 1000 .
We can then get logits( x , i )
≈ λ
i 1 logits( x , i 1 ) + ...
+ λ
i k logits( x , i k ) , i / ∈ { i 1 , ..., i k } , k ≪ 1000 , ∀ x ∈ X , (12)
where logits( x , i j ) , j = 1 , . . .
, k is the logits of network for category i
j , i .
e ., logits( x , i j ) =
W i j F ( x ) .
It is easy to see that outputs for category i are linearly decided by outputs for i 1 , ..., i k and are dominated by outputs for i 1 .
Fig.
4 demonstrates the solutions of Eq.
(12) for three different categories in ImageNet with η = 20 , and network architectures ResNet-50, GluMixer-24, and
Swin-T.
The results are surprising.
It shows that many categories of the network predictions are in fact ‘redundant’, as they are purely decided by the predictions of the other categories with simple linear coefficients.
In this case, the entanglement of different categories cannot be avoided, thus the network may perform poorly under domain shift.
An even more surprising finding is that, some very irrelevant categories hold the largest weights when deciding the predictions of the redundant categories, which means that the networks just neglect the unique representations of those categories in training and yield over-fitting when predicting them.
Related Work
Previous studies of rank deficiency in deep neural networks follow two parallel clues.
One is the study of rank behavior in specific neural network architectures.
Dong et al.
[15] studies deep networks consisting of pure self-attention networks, and proves that they converge exponentially to a rankmatrix under the assumption of globally bounded weight matrices.
Daneshmand et al.
[13] studies the effect of BatchNorm on MLPs and shows that BatchNorm can prevent drastic diminishing of network ranks in some small networks and datasets.
Both of those works avoid directly validating the behavior of network ranks in intermediate layers due to the lacking of efficient numerical tools.
An independent clue is the study of implicit self-regularization, which finds that weight matrices tend to lose ranks after training.
Martin and Mahoney [39] studies this phenomenon in infinitely-wide, over-parametric neural networks with tools from random matrix theory.
Arora et al.
[1] studies this phenomenon in deep matrix decomposition.
Those works focus on the theoretical behavior of rank of weight matrices induced by the training instead of network ranks.
Conclusion
This paper studies the rank behavior of deep neural networks.
In contrast to previous work, we focus on directly validating rank behavior with deep neural networks of diverse benchmarks and various settings for real scenarios.
We first formalize the analysis and measurement of network ranks.
Then under the proposed numerical tools and theoretical analysis, we demonstrate the universal rank diminishing of deep neural networks from both empirical and theoretical perspectives.
We further support the rank-deficient structure of networks by revealing the independence deficit phenomenon, where network predictions for a category can be linearly decided by a few other, even irrelevant categories.
The results of this work may advance understanding of the behavior of fundamental network architectures and provide intuition for a wide range of work pertaining to network ranks.
Acknowledgement
The authors thank Prof. Dangzheng Liu of the University of Science and Technology of China for disucssion and helpful advice.
This work was supported by National Key R&D Program of China under Grant 2020AAA0105701, National Natural Science Foundation of China (NSFC) under Grants 62225207 and U19B2038, and the University Synergy Innovation Program of Anhui Province under
Grants GXXT-2019-025.
Appendix Contents A Proofs
A.1 Proof to Lemma 1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
A.2 Proof to Theorem 1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
A.3 Proof to Lemma 2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
A.4 Proof to Theorem 2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
A.5 Proof to Theorem 3 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
A.6 Proof to Theorem 4 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
A.6.
Lyapunov exponents are limits of logarithms of subspace spectral norm divided by layer depth L . . . . . . . . . . . . . . . . . . . . . . . . . . .
A coupling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
A.7 Proof to Theorem 5 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
A.8 Proof to Corollary 1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
B Influences of Structures
C Orthogonal Initialization
D Code
E Experiments Setup
F Partial Rank
of the Jacobian:
Estimating
Lower Bound of
Lost
Rank
in Deep Networks F
Partial Rank of Jacobians under Different Input Patches . . . . . . . . . . . . . . .
G Estimating Dimension Diminishing in Features
A Proofs A.1 Proof to Lemma
This Lemma is the direct result of the rank theorem of manifolds .
Theorem 6 (Rank Theorem [25]) .
Suppose f : M → N is a smooth function from m -dimensional manifold M to n -dimensional manifold N , and Rank M , N ( J f )
= r .
Then for each x ∈ M , there exists a smooth chart ( U , m ) around x and a smooth chart ( V , n ) around f ( x ) , such that
[Equation]
(A13) is given by n ◦ f ◦ m − 1 ( x 1 , x 2 , · · · , x m ) =
( x 1 , x 2 , · · · , x m , 0 , · · · , 0) .
The rank of a function Rank M , N defined on the manifold is the rank under local chart systems of the input manifold M and output manifold N .
Let ϕ be the chart for point x ∈ O ⊂ M , and the identity map be the chart for point f ( x ) ∈ R d .
Then it is easy to find that
[Equation]
Then by Theorem 6, we know that
[Equation]
The last equal sign comes from the rank inequality of matrix multiplication Rank( AB ) ≤ min { Rank( A ) , Rank( B ) } , which we will discuss later.
A.2 Proof to Theorem
Proof to this Theorem needs Weyl’s inequalities [57] for singular values of sum of matrices.
Theorem 7 (Weyl’s inequalities) .
Let A , B be p × n complex matrices, σ i ( · ) be the i -th largest singular value of the matrix.
Then
[Equation]
Let p be the number of singular values of W and D .
By this theorem, we have
[Equation]
To measure the numerical rank, we need to estimate the relative quantities of singular values, which are,
[Equation]
Now assume that ϵ does not belong to the following set (which is a zero measure set in R + )
[Equation]
and Rank ϵ ( W ) =
r .
We know that
[Equation]
Thus, we have that ∀ δ < δ max ,
[Equation]
provided that δ max
[Equation]
[Equation]
Thus we can conclude
[Equation]
When Rank( W ) =
r < p , it is then easy to see if ϵ < σ r ( W ) σ 1 ( W ) , we have [Equation] W
[Equation]
Thus setting ϵ max =
σ r ( W ) σ 1 ( W ) , we can always have δ max acquired by Eq.
(A23), such that
[Equation]
A.3 Proof to Lemma
Let A i be the i -th column of matrix A .
Given two matrices A ∈ R m × n , B ∈ R n × d , we have
AB = ( AB 1 , · · · AB d ) .
(A27)
Thus for any 1 ≤ i 1 < · · · < i K ≤ d , ( AB ) i 1 , ··· ,i K =
( AB i 1 , · · · , AB i K ) =
A ( B ) i 1 , ··· ,i K .
(A28)
By the rank theorem [26] of matrices, we have
Rank(( AB ) i 1 ,
[Equation]
,i K )
[Equation]
B )
[Equation]
[Equation]
, (A29) and
[Equation]
(A30)
As ( B ) i 1 , ··· ,i K ) ⊂
B , it is straightforward to get that
[Equation]
B
[Equation] [Equation]
[Equation] [Equation]
(A31)
Thus
Ker( A
[Equation] [Equation]
[Equation]
(A32)
Then we have
[Equation]
Note that Rank( f 2 ◦ f 1 ) =
Rank( J f 2 J f 1 ) .
Then we complete the proof.
A.4 Proof to Theorem
The key to this principle is the rank theorem of matrices [26], which is
[Equation]
Note that Rank( AB ) =
Rank( B T A T ) and Rank( A T ) =
Rank( A ) .
Then we have
[Equation]
The dimension of a linear subspace will at least be zero, thus the above equations suggest
[Equation]
Applying this argument to the chain rule of differentials then yields the conclusion.
Further using
Lemma 1 gives the diminishing of intrinsic dimensions of feature manifolds.
A.5 Proof to Theorem
We first give the rigorous version of this theorem as follows.
Theorem 8.
Let e x be the exponential map from a small neighborhood
U x of point x on the input feature manifold to its tangent space at x , and v x = e x ( x ) .
Let X be the input manifold, s = dim( X ) , f i be the layer network, r = Rank( f i ) , and f i ( X ) be the output manifold.
If for almost everywhere on the input feature manifold, there is a unit vector v ∈ e x
( U x ) , such that the layer network f i satisfies
[Equation]
then dim( f i ( X ))
<
s .
If the number of such independent v in e x ( U x ) is k , then dim( f i ( X ))
≤ s − k .
Now we prove this theorem.
Note that Eq.
(A37) implies
[Equation]
As it is also easy to see
[Equation]
we can conclude
[Equation]
where 0 ̸ =
J e − 1 x v comes from the full rank property of exponential map and its inverse.
Thus we have
[Equation]
Specifically, if linearly independent v 1 , · · · , v k satisfy Eq.
(A37), we can conclude
[Equation]
As J e − 1 x has full rank due to the property of exponential map
[Equation]
we know that J e − 1 x v i , i = 1 , · · ·
[Equation]
k are linearly independent.
Then
[Equation]
Thus the rank theorem of matrices [26] reads
[Equation]
Combining this result with Theorem 6 proves our result
[Equation]
A.6 Proof to Theorem
The proof to this theorem relies on the existence of Lyapunov exponents of dynamic systems.
Given a linearized dynamic system
[Equation]
its (largest) Lyapunov exponent is defined as
[Equation]
Further, for a sequence of subspace L h ⊂ L r − 1 ⊂ · · · ⊂ L 1 ⊂ L 0 = R n , we can define the corresponding Lyapunov exponents of all those subspaces as
[Equation]
and we have
[Equation]
It may be surprising to find that such Lyapunov exponents exist, as v 0 can traverse the entire subspace L i − 1 \L i .
We will demonstrate the existence of the Lyapunov exponents for our case later in
Sec.
A.6.3, which is the classical results from the Furstenberg-Kesten theorem [19] and multiplicative ergodic theorem [47].
Before that, we will first assume the existence of those Lyapunov exponents for simplicity of analysis.
Now consider the case of function couplings
[Equation]
which has the Jacobian matrix
[Equation]
Apparently, the following dynamic system induces the Jacobi matrix of F ,
[Equation]
Thus its Lyapunov exponents are given by
[Equation]
for a chain of subspaces { 0 } =
L h +
[Equation]
⊂ L h
[Equation]
L h
[Equation]
⊂ · · · ⊂ L 1 ⊂ L
[Equation]
= R n
[Equation]
A.6.1 Lyapunov exponents are limits of logarithms of subspace spectral norm divided by layer depth L
We first demonstrate that the Lyapunov exponents are limits of logarithm of the spectral norm of F on L i − 1 \L i divided by layer depth L when L → ∞ , for i = 1 , ..., r .
It is easy to see
[Equation]
When L → ∞ , 1 L log ∥ v 0 ∥ 2 → 0 for any v 0 , we have
[Equation]
Let
[Equation]
Note that sup
[Equation]
and
[Equation]
where ∥ · ∥ 2 ,i denote the spectral norm of a linear operator constrained on L i − 1 \L i .Then
we have
[Equation]
Let e i 1 , · · · , e i k be a set of standard orthogonal basis of i k dimensional subspace L i − 1 \L i .
If the
Lyapunov exponents exist, by Eq.
(A55) we have for any ϵ > 0 , there is N ∈ N such that for all
L > N ,
[Equation]
Let v = (cid:80) i
k j =
α j e j ∈ L i − 1 \L i , where α j , i = 1 , · · · , i k , (cid:80)
i k
j
=1 α 2 j
= 1 is the coordinate of unit vector v under the basis e j , j = 1 , · · · , i k .
Assume that ∥ J F e 1 ∥ 2 ≥ ∥ J F e j ∥ 2 , j = 2 , · · · , i k .
We then have
[Equation]
Thus, if we set N 0 = max { N, 2 i k − 2+log i k ϵ } , then when L > N 0 we have 1 L
( i k − 1)+ 12 L log i k < ϵand
[Equation]
Combining Eqs.
(A60) and (A70), we have for any ϵ > 0 , there is N 0 ∈ N , such that when L > N 0 , we always have
[Equation]
Thus, if the Lyapunov exponents exist, i .
e ., the existence of limits of Eq.
(A53) , we have
[Equation]
A
[Equation]
A.6.2 Singular value distributions of Jacobian matrices of deep function coupling
In Sec.
A.6.1 we have proved that the Lyapunov exponents (if they exist) are limits of logarithms of subspace spectral norms divided by L .
Here we use this property to prove the deficiency of numerical ranks, i .
e ., Eq.
We first introduce the Courant-Fischer min-max theorem [26] of sigular values.
Theorem 9 (Courant-Fischer Min-max Theorem) .
Let A be a d × n complex matrix and σ i ( A ) denote its i -th largest singular value, i = 1 , · · · , min { d, n } .
Then we have
[Equation]
where V traverses subspaces of R n .
This theorem also serves as one of the definitions to singular values.
Now assume that dim( L 0 \L 1 ) = r , and we consider only the case of d = n for simplicity.
For any ϵ > 0 , we have N ∈ N such that when L > N ,
[Equation]
due to Eq.
(A55).
As dim( L 0 \L 1 ) =
r , by Theorem 9, we have
[Equation]
For v ∈ L 0 = R n and ∥ v ∥ 2 = 1 , as L 0 =
L 0 \L 1 ⊕ · · · ⊕ L h \L h +1 ( ⊕ denotes direct sum of linear quotient subspaces in the Banach space), there is v i ∈
L i − 1 \L i , i = 1 , · · · , h + 1 , such that
[Equation]
and
[Equation]
Then by the conclusion of Sec.
A.6.1, we have
[Equation]
Thus there is N 1 ∈ N , such that when L > N 1 , we have
[Equation]
As dim( L 1 ) = n − 1 + 1 , by Theorem 9, we have when L > N 1 ,
[Equation]
In conclusion, when L > N 0 = max { N, N 1 } , we have
[Equation]
Thus when L → ∞ , we have
[Equation]
J
[Equation] [Equation]
Using the same argument for σ 2 ( J F ) , · · · , σ n ( J F ) , we can find that if let ˆ λ 1 ≥ ˆ λ 2 · · · ≥ ˆ λ n be the
Lyapunov exponents counting repetitions, i .
e ., ˆ
[Equation]
i , if
[Equation]
then
[Equation]
Note that
[Equation]
Thus we have
[Equation]
As a consequence, Rank ϵ ( F ) ≤ r for any ϵ > 0 when L → ∞ .
A.6.3 Existence of Lyapunov exponents for Jacobian matrices of deep function coupling
In above analysis, we have proven Theorem 4 under the existence of Lyapunov exponents.
In this section, we introduce the classical result of multiplicatve ergodic theorem in the specific domain of random matrices, which is proposed by Furstenberg and Kesten [19, 20].
Theorem 10 (Multiplicatve Ergodic Theorem (Theorem 3.9 of [20])) .
Let µ be a probability measure on all convertible matrices of R n × n which satisfies
[Equation]
If each J f k independently follows µ , then we have a chain of subspaces { 0 } =
L h +1 ⊂
L h ⊂ · · · ⊂
L 1 ⊂
[Equation]
0 = R n and corresponding postive real constants λ
[Equation] [Equation]
λ
[Equation]
such that almost surely
[Equation]
which means the existence of the Lyapunov exponents.
Combining this theorem and the arguments above, we can finally prove Theorem 4.
A.7 Proof to Theorem
This theorem can be deduced from the Lyapunov components of Ginibre matrices (polynomial ensemble of square matrices sampled i.i.d from standard Gaussian).
Theorem 11 (Exact Lyapunov Exponent Distribution for Ginibre Matrices [43]) .
If µ in Theoremis standard Gaussian, then h + 1 = n , and
[Equation]
Combining this theorem with Theorem 4 can directly yield our result.
A.8 Proof to Corollary
This theorem is the direct result of Theorems 4 and 11.
Note that it is easy to get
[Equation]
for standard Gaussian µ .
B Influences of Structures
Skip Connection Skip Connection is the most direct method to solve rank diminishing at the initialization period.
In our formulation, the definition of a layer network requires it to accept inputs purely from its predecessor layer as
[Equation]
However, when we add a skip connection from its ancestor layer f s , s < i − 1 , we have x
[Equation]
A96)
It actually makes the coupling of layers
[Equation]
the true predecessor layer to f i , as
[Equation]
Thus the true layer depth is cut down by i − s , remaining L − ( i − s ) layers.
Skip connection is usually used with the residual network.
This structure can ease rank diminishing inside the layer ˆ f s , which we will discuss later.
Overall, skip connection shortens the length of the chain of Jacobian matrices, thus restraining rank diminishing.
[Figure]
BatchNorm Some previous works [13, 5] discuss the role of BatchNorm in restraining rank diminishing.
They show that BatchNorm may slow down the speed of rank diminishing in neural networks in some specific cases.
Residual Network Residual Network is another useful tool to restrain rank diminishing at the initialization period.
The residual network r has the form
[Equation]
where x o and x i are the output feature and input feature, respectively.
Usually the residual term
Res( x i ) is small compared with the input x
i at the initialization period, as is pointed out by related works [22].
Assume that
[Equation]
where ϵ is very small.
Then we have
[Equation]
is a diagonally dominant matrix, thus it has full rank.
This means its kernel space Ker( J r ) = { 0 } is a zero dimension space.
Thus by the Rank Theorem, for any predecessor layer f , r ◦ f will not lose rank as
[Equation]
However, in the well-trained ResNet18 and ResNet50 networks, we still observe considerable diminishing of ranks in Fig.
The reason for this phenomenon could be that, during training the magnitude of the residual term Res( x ) becomes large.
Then the argument above no longer stand and hence the rank becomes lower.
Taking the 16-th layer of the ResNet50 as example, we find that the rank of this layer drops from 530 to 119 after training, while the relative magnitude ∥ Res( x ) ∥ 2 ∥ x ∥increases from 0.5127 to 0.9557 after training.
This may explain why the residual connection is less effective in preventing network ranks after training.
Influences of the Pooling Layers and Width To better validate the rank behavior of deep neural networks ( e.g. , ResNet), we remove the operation of downsampling in the ResNet so that the feature dimension ( e.g. , x ∈ R H × W × C =802 , 816 for ResNet-50) will not change.
This modified ResNet can exclude the effect of pooling layers and changes of layer width.
As shown in Fig.
A5, we show the partial rank of Jacobian matrices and perturbed PCA dimensions at the i -th layer of the modified ResNet-18 and ResNet-50 on ImageNet.
We can find that the curves of partial ranks and
R a t i o
o f S i n g u l a r s
R a nk o f Ja c o b i
[Figure]
perturbed PCA dimensions share a similar and consistent trend of decreasing as the initial networks.
The consistent behavior of partial ranks and perturbed PCA dimensions also shows a monotonic decreasing property of network ranks.
Thus the overall trend of rank diminishing seems to be independent of the pooling layers and changes of width.
On the other hand, the partial rank witnesses a considerable drop near the terminal layer after applying pooling layers, which means it does have an effect on the network ranks.
C Orthogonal Initialization
Previous work [62] has demonstrated that under carefully designed initialization rule, we can train very deep (1,0000 layer) plain CNNs.
It is then curious to investigate that whether the phenomenon of rank diminishing happens in this case.
To this end, we empirically measure the numerical rank of Jacobi matrices and perturbed PCA dimensions of an extremely deep CNN initialized by the
Delta-Orthogonal method [62].
While computing the Jacobi matrices of very deep networks is infeasible in time, we only compute the 4-1,004 layer of the network.
We omit the first 4 layers as there are downsampling architectures.
We measure two metrics of each layer:
the numerical rank of the Jacobi matrix; 2.
the ratio between sum of small singular values and large singular values (cid:80)
i
[Equation]
11 σ i (cid:80) 1 i =1 0 σ i , where 3,072 is the width of this network, and σ 1 ≥ σ 2 ≥ · · · ≥ σ 3072 are singular values of the Jacobi matrix.
As shown in FigA6, a generally decreasing trend of the Jacobi rank and singular ratio can be observed.
This result is consistent with Theorem 4.
Although orthogonal initialization can suppress rank decrease to a certain extent, the impact of low rank cannot be ignored when the network is deep enough.
D Code
Algorithm A1 provides the pseudo-code of partial rank of the Jacobian.
The implementation of the
Algorithm A1 can refer to the ‘rank_jacobian.py’ python file.
Algorithm A2 provides the pseudo-code of perturbed PCA dimension of feature spaces.
The implementation of the Algorithm A2 can refer to the ‘rank_perturb.py’ python file.
Algorithm A3 provides the pseudo-code of the classification dimension.
The implementation of the Algorithm A3 can refer to the ‘run_cls_dim.py’ python file.
Algorithm A4 provides the pseudo-code of independence deficit.
The implementation of the Algorithm A4 can refer to the ‘run_deficit.py’ python file.
Arch.
Network
Activ.
[Table]
[Table]
MLP-like
GluMixer
[Table]
[Table]
[Table]
Transformer
[Table]
E Experiments Setup
Information of those networks used in validations is listed in Tab. A2.
When measuring rank, we set ϵ = eps × N , where eps is the digital accuracy of float32 ( i .
e ., 1 .
19 e − 7 ) and N is the number of singular values of the matrix to measure.
This threshold represents the minimum digital accuracy of numerical rank we can capture in data stored as float32 .
All the experiments are conducted on the validation set of ImageNet and NVIDIA A100-SXM-80G GPUs.
F Partial Rank of the Jacobian: Estimating Lower Bound of Lost Rank in Deep Networks
To enable the validation of trend of the network ranks, we propose to compute only the rank of sub-matrices of the Jacobian as an alternative.
Those sub-matrices are also the Jacobian matrices with respect to a fixed small patch of inputs.
Rigorously, given a function f and its Jacobian J f , we denote partial rank of the Jacobian as the rank of a sub-matrix of the Jacobian that consists of the j 1 -th, j 2 -th,..., j K -th column of the original Jacobian
PartialRank( J f ) = Rank(
[Equation]
where 1 ≤ j 1 < . . .
<
j K ≤ n.
We can efficiently compute sub-matrix of the Jacobian by zero padding to small patches of input images.
For any data point x ∈ R n , let Sub( x , j 1 , ..., j K ) =
( x j 1 , ..., x j K ) T ∈ R K , and ψ pad Sub( x , j 1 , ..., j K ) to the spatial size of x with zeros: ψ (Sub( x , j 1 , ..., j K ))
= (0 , .., 0 , x j 1 , 0 , ..., x j K , 0 , ..., 0) T ∈ R n with ψ (Sub( x , j 1 , ..., j K ))
j k = x j k , k = 1 , ..., K. We then have J f ◦ ψ =
Sub( J f , j 1 , ..., j K ) .
As K can be very small compared with n , computing J f ◦ ψ can be very cheap in time and space.
The partial rank of Jacobian matrices of the network layers measures information captured among the spatial footprint j 1 , ..., j K of the original input.
They inherit the order relation of the rank of full Jacobian matrices.
Thus we can validate the rank diminishing of network Jacobian matrices through the partial rank.
Lemma 2.
For differentiable f 1 , f 2 , | Rank( f 1 ) − Rank( f 2 ◦ f 1 ) | ≥ | Rank(Sub( f 1 , j 1 , . . .
, j K ))
−
Rank(Sub( f 2 ◦ f 1 , j 1 , . . .
, j K ))
| , ∀ 1 ≤ K ≤ n, 1 ≤ j 1 , . .
, j K ≤ n .
Thus variance of partial ranks of adjacent sub-networks gives a lower bound on the variance of their ranks.
F.1 Partial Rank of Jacobians under Different Input Patches
In Fig.
A7 we report partial ranks of different input image patches (marked with colored boxes in Fig.
A7(a)) for the layers of ResNet-50 on ImageNet.
We can find that the curves of partial ranks share a similar and consistent trend among different input patches.
Thus, picking one patch, for example, the central patch of 16 × 16 × 3 pixels we use in Sec. 6.1, could be enough to demonstrate the overall behavior of network ranks.
The consistent behavior of all those partial ranks also shows that partial rank is a good tool to investigate network ranks.
G Estimating Dimension Diminishing in Features
Measuring the intrinsic dimension of feature manifolds is known to be hard.
However, we manage to give a rough estimation to the dimension dropped by different layer networks.
To do this, we use a new metric called the Perturbed PCA Dimension.
It measures the expectation of PCA dimension of small local neighborhoods over the feature manifold.
P a r t i a l R a nk P a r t i a l R a nk
The 𝒊𝒊 -th Layer of ResNet
P a r t i a l R a nk
P a r t i a l R a nk
The 𝒊𝒊 -th Layer of ResNet
The 𝒊𝒊 -th Layer of ResNet The 𝒊𝒊 -th Layer of ResNet
The 𝒊𝒊 -th Layer of ResNet The 𝒊𝒊 -th Layer of ResNet
The 𝒊𝒊 -th Layer of ResNet
P a r t i a l R a nk
P a r t i a l R a nk P a r t i a l R a nk
[Figure]
Let F k be the k -th sub-network of the whole network F .
We want to measure the Perturbed PCA
Dimension of F k ( X ) , where X is the input data domain.
To this end, we compute
[Equation]
where PCADim for a set is the number of PCA eigenvalues larger than a threshold ξ .
For each point x , we sample 50,000 different perturbation ϵ to compute the PCA dimension of the neighborhood of
F k ( x ) .
When computing the PCA dimension, we set δ = 1 e − 3 and ξ = 1 .
19 e − 7 × 50000 × eig max , where eig max is the largest PCA eigenvalue.
We then compute the mean value of PCA dimensions over the neighborhood of 100 random samples in the validation set of ImageNet as the final result.
We do not use PCA dimension of the feature manifolds directly as it is unable to cope with the highly non-linear structure of intermediate feature manifolds.
However, the Perturbed PCA Dimension is able to estimate the dimensions of local neighborhoods of points in the feature manifolds.
As local neighborhoods can be viewed as linear if the network is smooth, the Perturbed PCA Dimension could be more feasible than PCA dimension in our case.
We provide the pseudo-code to compute the
Perturbed PCA Dimension in Algorithm A2.
However, the perturbation is made in the ambient space of the input data manifold X rather than the data manifold itself.
Thus this estimation may considerably overestimate the intrinsic dimensions of feature manifolds.
So we merely care about how many Perturbed PCA Dimensions are lost by a sub-network instead of its own Perturbed PCA Dimension.
We call this quantity ∆ Dimension, which is the difference between the Perturbed PCA Dimension of the current layer and that of the input layer for the given deep network.
As shown in Fig.
A8, we show the dropped dimensions of different feature layers of the CNN, MLP, and Transformer architectures on ImageNet.
The results show that the Perturbed PCA Dimensions of feature manifolds of most networks decrease as the networks get deeper, thus confirming the rank diminishing principle we propose in Theorem
[Figure]
[Table] [Table]
[Table]
: input images # model: network # target: ground-truth labels # acc_ratio: threshold for measuring intrinsic dimensions of final features def PCA(X, n_components): n = X.shape[0]
X_mean = mean(X, dim=0, keepdim=
True) X
= X - X_mean covariance_matrix = 1 / n * matmul(X.T, X) eigenvalues, eigenvectors =
evd(covariance_matrix, eigenvectors=
True) eigenvalues = norm(eigenvalues, dim=1)
# modulus of complex numbers idx = argsort(-eigenvalues) eigenvectors =
eigenvectors[:, idx] eigenvectors =
eigenvectors
[:, :n_components] return eigenvectors def Feature_projection(X, V): X_proj =
zeros_like(X) for component_idx in range(V.size(1)): eig_vec =
V[:, component_idx].unsqueeze(-1) eig_vec_norm = eig_vec / norm(eig_vec, p=2, keepdim=
True) w_proj = matmul(X, eig_vec_norm)
X_proj_i = w_proj * eig_vec_norm.
T X_proj += X_proj_i return X_proj def Intrinsic_dimension(image, model, target, acc_ratio=0.95): # pre-extract features and calculate original classification accuracy feats = model(image)
# [n_samples * n_channels] acc_ori =
calc_acc(feats, target) for n_component in range(1, feats.size(1)): # compute the eigenvalues and eigenvectors of a real square matrix components =
PCA(feats, n_component) # [n_channels * n_component] # reconstruct features with principal components feats_rec = Feature_projection(feats
[Table] [Table]