{'fraction_non_alphanumeric': 0.04378276368211365, 'fraction_numerical': 0.011323128538477669, 'mean_word_length': 3.9338919925512106, 'pattern_counts': {'":': 0, '<': 12, '<?xml version=': 0, '>': 12, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 18, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
Deep limits and cut-off phenomena for neural networks

We consider dynamical and geometrical aspects of deep learning. For many standard choices of layer maps we display semi-invariant metrics which quantify differences between data or decision functions. This allows us, when considering random layer maps and using non-commutative ergodic theorems, to deduce that certain limits exist when letting the number of layers tend to infinity. We also examine the random initialization of standard networks where we observe a surprising cut-off phenomenon in terms of the number of layers, the depth of the network. This could be a relevant parameter when choosing an appropriate number of layers for a given learning task, or for selecting a good initialization procedure. More generally, we hope that the notions and results in this paper can provide a framework, in particular a geometric one, for a part of the theoretical understanding of deep neural networks.


Introduction
In this paper, we develop a geometric toolkit which we propose as a means to study neural networks, in particular as the depth tends to infinity. Viewed in this sense, we can deduce properties of the limit of neural networks as the number of layers go to infinity provided that the layers preserve certain distance functions (metrics).
As a starting point we will consider neural networks with random layers, which can occur from dropout Srivastava et al. (2014), Bayesian neural networks Neal (2012), neural networks with noise (Neural SDE) Liu et al. (2019), or simply random initialization. The assumptions on the dependence between subsequent layers is weak and we only assume stationarity.
Our analysis shows that under the assumption of stationarity, if one can find a metric space for which the "layer transformations" of the neural networks is non-expansive, then the limit and its growth rate can be described using powerful tools from ergodic theory.

Background
As is by now well known, certain deep networks perform better than their shallow counterpart, see for instance He et al. (2016). Fairly recently Belkin et al. (2019) observed a phenomenon later dubbed "Deep Double Descent" in Nakkiran et al. (2020). The deep double descent means that for deep networks, after a certain width threshold the generalization properties becomes better and better even though the class of networks becomes increasingly complex, Hornik et al. (1989). However, as mentioned above, also deeper networks seems better in terms of generalization, which suggests there is a regularizing effect of depth under certain conditions, similar to deep double descent.
The wide limit of neural networks is fairly well studied, see for instance Neal (1996); Mei et al. (2018); Jacot et al. (2018); Rotskoff and Vanden-Eijnden (2018). However the deep limit is not a particularly well defined concept and there are many different ways to view it. One of the more practically successful ones are the Neural ODEs, introduced by Chen et al. (2018), which can be seen as a deep limit of residual networks (Thorpe and van Gennip (2018); Avelin and Nyström (2021)). The discrete model for these continuous neural networks can be formulated as where T i represents a layer in the neural network. In the case of Neural SDEs (Liu et al. (2019); Tzen and Raginsky (2019)), or in the Bayesian framework (see for instance Neal (2012)) we can view each layer as being random. Furthermore, the special case of i.i.d. random layers is present in the random initialization of the network, and is in fact a very important aspect to understand when it comes to training neural networks, Sutskever et al. (2013).
A key observation in the above formulation is that the discrete form (1) represents an approximation of the ODE i.e. the discrete system is an approximation of a fixed time horizon ODE, with a time-step of size 1 n. Another point of view is to consider a fixed time-step and consider the behavior of the system as n → ∞, i.e. of In a sense the networks in (3) represent a duality of thought compared to (1), in that either we consider a deep neural network as consisting of many distinct layers or we consider a single (time dependent) network being repeated in a recurrent fashion, "layer" is represented by time. This connects deep neural networks to the concept of a recurrent neural network and in a sense they are the same, specifically neural ODEs and neural SDEs which are even trained using recurrent back-propagation (real-time recurrent learning), see Chen et al. (2018); Liu et al. (2019); Robinson and Fallside (1988); Rohwer (1990); Tzen and Raginsky (2019); Williams and Zipser (1989).
In the context of Bayesian neural networks, there has recently been some progress in establishing the deep limits of these as certain Gaussian processes, see Agrawal et al. (2020); Dunlop et al. (2018); Duvenaud et al. (2014).
According to E et al. (2020), at the continuous level many machine learning models are the gradient flow of a reasonably nice functional, and they argue that this is a reason for models such as (1) (ResNets) are numerically stable, Hanin (2018); Schaefer et al. (2008). They also suggest that for (3) one should expect trouble since there is no continuum limit. This is true to some degree, but one should keep in mind that even a standard ResNet does not have the scaling factor 1 n in front of T n , thus one could argue that it is more reasonable to consider the limit of fixed time-step dynamics. Of course this may not have a limit but perhaps a certain rescaling does, for instance, one could consider lim n→∞ 1 n log(x n ), or lim n→∞ 1 n x n .

Our contribution
In this paper we take the viewpoint of (3) and we rephrase the update equation as x n+1 = T n (x n ). The problem is now one of discrete (possibly chaotic) dynamical systems. The main contribution of our paper is that we develop a framework to study deep neural networks from a geometric perspective. Specifically it allows us to read out certain stability properties whenever there exists a metric which is preserved by the network layers. Depending on the metrics involved, it can tell us if the networks tend to satisfy some regularity as we go deeper, even though in principle the networks can become arbitrarily complex mappings (Lu et al. (2017)). This serves as an indication as to when one would observe the "Deep Double Descent" phenomenon with respect to depth. Note that we study the network directly without worrying about how we obtained said network. We consider stationary sequences of layers, which can cover for instance a sequence correlated layers for which the correlation tends to zero as we go deeper.
In the context of independent, identically distributed (i.i.d.) random layers, which corresponds to the random initialization of the weights in the network, we perform a few experiments where we observe a cut-off phenomenon. This means that for a given type of neural network there is a certain number of layers where the network behaves very differently. We call this its cut-off depth. The cut-off phenomenon was first discussed in card shuffling by Aldous and Diaconis (1986) who showed that seven shuffles are enough. It remains to understand the full significance of the cut-off depth for deep learning.
In summary, part of the rationale for our study is: • understanding how the function class evolves as the number of layers go to infinity.
• understanding if the discrete time-step model leads to a cut-off phenomenon? That is, is there a threshold amount of layers for which the space of output functions of the network increase significantly? • the randomness of our mappings T i is a way to model a host neural networks, including standard regularization techniques, Bayesian networks, other noise injected models or random initialization.

The dynamics of deep neural networks
Let X ⊆ R d denote the space which contains the input information as well as the intermediate data traveling through the hidden layers, in the notation below, x n ∈ X for all n. It could be the full vector space, or a subset such as the positive cone or a unit cube. Each layer defines a transformation T ∶ X → X typically of the form: where W is a matrix, called weights, and b a vector, called bias vector. Note that this is just an example and we can in fact have T being a small network. The activation function σ is a non-linear function σ ∶ R → R that is fixed for the whole network and is applied to each coordinate. Two standard choices for σ(t) are max{0, t}, called the rectified linear unit (ReLU), and tanh(t) (TanH). The former has been observed to often work very well in practice and the latter has the advantage of being a diffeomorphism R → (−1, 1). Other common choices are min{1, max{0, t}} and the sigmoid or logistic function 1 (1 + e −t ).
As mentioned in the introduction, in deep learning one uses several layers, sometimes even up to a thousand. We denote these n layer transformations, T 1 , ..., T n . In order to gain some theoretical understanding for the role of the number of layers, the depth, in neural network, we are interested in what happens to the neural network when n is large, or n → ∞. There are now in fact two possible dynamics to look at, first, new layers are added at the end just before the final output, or second, new layers are added just after the initial input. For a given initial input x 0 ∈ X, these two dynamics correspond to, respectively, x n = T n T n−1 ...T 1 x 0 (4) and x n = T 1 T 2 ...T n x 0 .
We can view these dynamics as a representation of transfer learning. Where (4) corresponds to adding a new layer at the end, which is the standard way transfer learning is used. On the other hand (5) corresponds to keeping the last layers and inserting a new layer at the beginning, this can be seen as transfer learning in the context of domain adaptation. Note that if we take the maps randomly, or more precisely independent and identically distributed (i.i.d.), then for each fixed n and given x 0 the distributions of x n are the same. But if we study the dynamics, the evolution x n of an individual x 0 then these two dynamics behave differently because of the non-commutativity of the layer transformations. In addition to these two "input dynamics" we will also consider "output dynamics". At the last hidden layer one often has a decision function f ∶ X → Y , where Y is also a subset of some vector space. For example, f is in many cases an indicator function of some set or a smooth approximation thereof.
Like the transpose of matrices, or more precisely the adjoint of operators which transforms linear functionals instead of vectors, we can look at the effect of the layers on the output function. We can thus let the layers and dynamics transform the decision function to a function that is then directly applied to the initial input. In other words, we are pulling back the decision function to the input as it were. This is the dual dynamics. In formulas, Note that orders get reversed just like for the transpose of matrices: and corresponding to the second dynamics above:

Framework and strategy
We introduce a geometric viewpoint on neural networks. In several of the most poplar network models in deep learning, we exhibit an associated metric space on which the layer maps act as non-expansive maps.
Once we have this one could potentially use the contraction mapping principle, in the version of a sequence of maps, which composed has a summable contraction constant. We refer to the review by Diaconis and Freedman (1999) for more information.
But often in our context such strong contraction property is not available, but then we instead have the non-commutative ergodic theorem in Gouëzel and Karlsson (2020), recalled below as Theorem 1, as a main tool.
In order to probe the neural network to understand a bit better the role of the number of layers, we apply these ergodic theorems to stationary sequences of layer maps. In experiments we observe a cut-off phenomenon, see Section 7.
We will in this paper analyze the following two dynamical systems: These cover the two dynamics above: adding layers at the beginning or at the end, respectively. It is this order that corresponds to random walks, where each step y n is not far from y n−1 . Expressed differently, these orders will make it possible to extract some coherent asymptotic behavior of x n in the first case and f n in the second. (For certain quantities such as the probability distribution or the basic growth the order does not matter. This will be seen later).

Ergodic theorems
To better understand where the tools of ergodic theory come from let us recall the classical law of large numbers (LLN). It asserts that for i.i.d. random variables X i with E[ X i ] < ∞, One can wonder if there is a similar law when the random variables are not commuting, for example the product of randomly selected matrices. Notice that in the non-commutative case it is not obvious how to form an average, and one complication is clear a priori : the limits typically will depend on the order of the maps, in contrast to the classical LLN. The results concerning such non-commutative ergodic theorems are of two types, subadditive ergodic theorems and multiplicative ergodic theorems. Let us begin by describing Kingman's subadditive ergodic theorem Kingman (1973) as it is a generalization of the LLN to operations that are subadditive. As a simple special case (the Furstenberg-Kesten theorem) let us consider a sequence of i.i.d. random matrices A i ∈ R N ×N and the functions a(i, j) = log A i . . . A i+j . This is subadditive in i, i.e. a(1, i + j) ≤ a(1, i) + a(i, j). The subadditivity follows from the basic norm inequality. In this case, Kingman's subadditive ergodic theorem asserts that lim n→∞ a(1, n) n → .
The limiting value is deterministic like in the LLN but on the other hand there is no good formula for its value. Multiplicative ergodic theorems are stronger in the sense that they say more about the limit, loosely speaking they give an asymptotic direction of the limit. The prototypical multiplicative ergodic theorem is Oseledets' theorem Oseledets (1968), which relates to random products of matrices.
The setting for these ergodic theorems and for us here is that of integrable ergodic cocycles. This corresponds to stationary sequences in probability theory language, a special case of which is the i.i.d with finite first moment setting. Another special case is the mixing case where one has asymptotic independence.
We will call such integrable ergodic cocycles simply stationary sequences (with the integrability condition implicitly understood). Technically it means that we have an underlying probability measure space (M, µ), µ(M ) = 1, and a measurable transformation L ∶ M → M that preserves the measure µ(L −1 A) = µ(A) and is ergodic, which means that every Linvariant set has measure either 0 or 1. Finally we have a measurable map from M to a set of layer maps, m ↦ T m , so that for the metric under consideration, all distances involved are measurable and Note that this condition is independent of x since each map T m is non-expansive in the metric.
Consider now a stationary sequence of random matrices T i ∈ R N ×N , then Oseledets' theorem states that the value of λ is not random but depends on x, and there is at most N different values, which are called Lyapunov exponents. A good way of understanding the Lyapunov exponents is to consider the special case where all the T i 's are the same matrix, in this case we just taking powers of this matrix and the Lyapunov exponents are just the logarithm of the absolute value of the eigenvalues.
Oseledets' theorem only applies to linear maps (or the derivative cocycle of a diffeomorphsism), but we need to analyze non-linear maps since we have an activation function. To describe and understand the dynamics of such more general settings we should define something quantitative, like a norm or a metric. For example, to measure how close one decision function is to another, or the distance between two information vectors. These norms and distances should be preserved or at least not increase when a transformation is applied to any two points. Specifically, Let d denote a metric on either X or some space L of functions X → Y . We are interested in metrics that are semi-invariant, i.e. metrics that for a given map U satisfies for all z and w in X or L, respectively. Correspondingly we will call a mapping that has a semi-invariant metric, as a non-expansive map with respect to said metric.
We choose layer transformations T k at random (a stationary sequence). We let z n denote either of the two random processes, Fix d a semi-invariant metric wiht respect to all the layer maps T k . Like in the matrix example above, it is easy to see that d(z 0 , z n ) is then a subadditive process, see for example Karlsson and Ledrappier (2011); Gouëzel and Karlsson (2020) (this is most clearly written with ergodic theoretic formalism). Then by Kingman's subadditive ergodic theorem Kingman (1973) we have that exists a.s. This can be viewed as the existence of a basic regularity or growth. This holds for all the dynamics considered, including the reverse orders.
Multiplicative ergodic theorems refine this convergence, in the way that it predicts a directional behavior of z n (compare again with the matrix case above). The precise statement, which in fact generalizes Oseledets' theorem above, is as follows: Theorem 1 (Gouëzel and Karlsson (2020)) For any stationary sequence of maps as above, with z n denoting the orbit, there exists a.s. a metric functional h (that is a priori random) such that lim In order to apply this general theorem we need to understand what the metric functionals are for a given metric, see Appendix A.
In summary, the strategy we suggest is as follows: 1. Given a selected type of layer maps, find a metric space on which the maps act nonexpansively.
2. Determine the metric functionals of this space 3. Apply the non-commutative ergodic theorem and interpret the result in the given situation.
Moreover, we believe that already the first step, the metric setting, will have other interests for deep learning, different from the application of ergodic theorems.

Metric spaces
A metric space is a set with a distance function. In recent decades it has been realized that significant geometrical arguments work in such a general setting even without any differentiability. The subject is now often called metric geometry and has begun to infiltrate other areas, such as computer science.
Here we now turn to describing some metrics that are relevant in our context. The most basic metric space is the euclidean space of some finite dimension. Here the metric is given by d(x, y) = x − y where the norm comes from a scalar product.
Convex cones in vector spaces admit several useful choices of metrics with important maps being non-expansive, we refer to the excellent book Lemmens and Nussbaum (2012) for full information. We give some special cases of this here. Given a finite dimensional real vector space, consider the set X of vectors having all its entries positive. Thus X is a generalized first quadrant, a convex cone. Consider the following expression in terms of the coordinates x(i) and w(i) of the vectors x, w ∈ X. Note that f is asymmetric in its arguments, so in order to build a metric, we need to symmetrize it. It is also clearly not necessarily positive. There are two options, the Thompson metric and the Hilbert projective metric ("projective" refers to that it is a distance function between lines, while the distance between two proportional vectors are easily seen to be 0. The triangle inequality is not obvious, but we refer again to Lemmens and Nussbaum (2012) for that.) The Thompson's metric is defined as: in terms of the coordinates x(i) and w(i) of the vectors x, w ∈ X. This makes the cone X into a metric space and its main feature is that any order-preserving, subhomogeneous map of the cone into itself is a non-expansive map in this metric, for more information see Section 6.1. The Hilbert metric is instead This is also obviously a symmetric expression. On the other hand it clearly is 0 on rays, homogeneous maps are non-expansive in this metric. In one possible approach to Oseledets' theorem, one looks at the associated action of the matrices on the space of positive scalar products on the underlying vector space, see Karlsson and Ledrappier (2011) and references therein. Since our maps are not linear we cannot do the same. We will instead suggest to look at a much larger space, namely distance functions either on R N or the cube. To illustrate these ideas we fix the cube X = [−1, 1] N and use TanH which map the whole vector space diffeomorphically onto the open cube. Let M be the set of distance functions on X bi-Lipschitz equivalent to the original distance defined by a norm ⋅ . Here is a metric on M : Notice that for two distance functions that are K-bi-Lipschitz to each other, 0 < D(d 1 , d 2 ) < ∞. For the optimal K > 1 their distance would be log K. This function is clearly symmetric and D(d 1 , d 2 ) = 0 if and only if d 1 = d 2 . The triangle inequality is also satisfied because of the obvious properties of sup and log, like for the Thompson metric above. So (M, D) is a metric space. If T are diffeomorphisms then obviously this metric is invariant under T * which maps d to T * d(x, y) ∶= d(T x, T y), since T just permutes the underlying set, leaving the supremum invariant. Suppose T is merely injective (otherwise there would occur a division by zero), then T is non-expansive in view of the inequality: From this perspective, it seems that injectivity is important, TanH and invertible matrices gives (non-surjective) isometries of (M, D). Other activation functions would also be possible, but not ReLU.
In one dimensional dynamics, say in the study of diffeomorphisms f of a finite interval I, one finds the following quantitative measures of distortion and distance. First out is This has subadditive properties under composition of maps, see Navas (2018). In particular if one takes a random composition and divides by n, this converges a.e. to a deterministic value, called the asymptotic variation.
Another measure of distortion is see Deroin et al. (2007). D is subadditive with respect to compositions f n and symmetric with respect to f and the inverse f −1 . We can make this into a metric as follows, the distortion metric: but one can also consider a Thompson version. Furthermore, Theorem 1 also holds for asymmetric distances, see Gouëzel and Karlsson (2020), this allows us to even consider just half of it, i.e taking away y.
We can extend the distortion metric to higher dimension by considering the Jacobians instead of the derivatives. Let us consider diffeomorphisms f, g ∶ Ω → Ω in R N , then we can consider the Jacobian matrix J f = ∂f i ∂x j and the Jacobian determinant J f . Let us define the pseudo-metric The second to last follows from det(AB) = det(A) det(B) and the last step follows from the fact that h is a diffeomorphism.
In the case where h ∶ Ω → Ω is not a diffeomorphism with non-singular Jacobian, they are non-expansive in the view of

Main results
In this section we will use our previously outlined strategy to derive conclusions about the deep limit of neural networks. We will be employing both subadditive and multiplicative ergodic theorems to do so.

Positive models
We begin our exposition into explicit examples, by considering what we call positive models. That is, layers that can only produce positive output. To be specific, let us take for X the cone of vectors in R N with all coordinates ≥ 0. The layer maps T (x) = σ(W x + b) are such that W is a matrix with every entry ≥ 0 and same for b. Finally σ is an activation function which is increasing and satisfies σ(λx) ≤ λσ(x) for every λ > 0 and x ≥ 0, (note that this implies that σ(0) = 0). For example, ReLu, TanH, and the sigmoid. Note the following properties: • W preserves the cones, i.e. maps X into X. So does b and finally also σ. Therefore T ∶ X → X. (With ReLU this is true without assumptions on W and b.) • In fact, more is true, if x ≤ y in the partial order defined by the cone (i.e. all components of x are smaller or equal to those of y) then by the positivity of W and b as well as the increasing property of σ, it holds that T x ≤ T y.
Such maps are called order-preserving.
Example 1 Let us consider the 1-dimensional case, in this case a, b, x ∈ R. Let us consider the sigmoid σ(x) = 1 1+e −x and prove that σ(ax + b) is subhomogeneous for any b > −2 if a > 0. First assume that λ ∈ (0, 1]. Call f λ (x) = λσ(ax + b) and g λ (x) = σ(aλx + b). We will prove the strict inequality f λ (x) < g λ (x), assume now that for an x 0 there is a λ x 0 ∈ (0, 1] such that f λx 0 (x 0 ) = g λx 0 (x 0 ) then let us differentiate w.r.t λ and see where in the above we have used that which only holds for b > −2 and can be proven by straightforward computation. Note that this implies that for λ < λ x 0 we have f λ (x 0 ) < g λ (x 0 ). Now note that when λ = 1 we have f (x) = g(x) for all x, by the above argument the strict inequality carries to all λ ∈ (0, 1) for all x.
Notice that this example generalizes to positive matrices a and vectors x as long as the activation function is applied component-wise (as usual) and the vector b is greater than −2 in each component.
Example 2 Let us again consider the case σ(x) = 1 1+e −x and prove that given a positive matrix W then for any b the mapping T x = σ(W x + b) is order preserving. By the definition of order preserving we need to prove that given x ≤ y we have T x ≤ T y. Even though W x + b might not be mapped into X if b is not a positive vector, we still have that (W y+b)−(W x+b) ∈ X. This together with the monotonicity of σ gives that T is order preserving on the positive cone.
Collecting the above, we may thus formulate: Proposition 3 Given a matrix W with positive entries, a vector b with entries larger than −2, and σ(x) = 1 1+e −x the sigmoid activation function. Then the associated layer map T (x) = σ(W x + b) is non-expansive with respect to the Thompson metric on the standard positive cone.
Example 3 Consider now the ReLU activation function σ(x) = max{x, 0}. We affirm that the mapping T x = σ(W x + b) is subhomogeneous if b ≥ 0 and W is arbitrary. To see this: for any 0 < λ < 1, we have And as already remarked, if all entries of W is positive, then T is order-preserving as well.
We thus have some interesting examples of order-preserving and subhomogeneous layer transformations and since these properties are preserved under composition we get a rich bank of examples. As was recalled above, the positive cone admits a metric d, the Thompson metric, which is semi-invariant under such maps, i.e.
for all x, x ′ ∈ X.
In the following theorem we consider the mappings T ∶ X → X to be random in a stationary way and quite general, but we will keep the above examples in mind. The point is here that in order for our dynamics to have a well defined limit we consider the "layers" added to the beginning of the network instead of at the end, i.e. we are interested in In conclusion, applying Theorem 1 we get: Theorem 4 Let X be the positive cone in R N and let T i ∶ X → X be a stationary sequence of maps that is order preserving and subhomogeneous. Let x n = T 1 T 2 . . . T n x 0 , for a fixed x 0 ∈ X. Then lim n→∞ sup i x n (i) 1 n = e λ and there is a (random) coordinate 1 ≤ i 0 ≤ d such that lim n→∞ x n (i 0 ) 1 n = e λ .
The latter statement excludes a certain spiraling inside the cone.

Unitary case
In the case of positive models that are order preserving and subhomogeneous, we get two things, first of all there is essentially exponential growth of the components of the trajectories, secondly we where able to determine the direction of such a trajectory. The subhomogeneity and order preserving transforms allowed us to find a metric which made the maps semi-invariant, if we on the other hand loosen the restrictions and consider general transforms we have the problem of finding good metrics. However if we instead restrict the matrices W to be unitary (spectral norm 1) then even if we consider fairly general norms we still get a non-expansive mapping. In this case we can also deduce the specific form of the metric functional which gives us a very concrete result. To describe our situation let us begin by taking X = R N together with a norm ⋅ N and layer maps T (x) = W T σ(W x + b) such that the corresponding operator norm W N ≤ 1, b general and σ which satisfy σ(x) − σ(y) N ≤ x − y N (i.e. Lipschitz with constant 1, or non-expansive) when applied to vectors (component-wise as always). The point of having the layer transformations in the form given above, is that it is a popular layer type that is used in for instance ResNets (He et al. (2016)) and provides us with a layer that can span the entire vector space. Let us now remark on the 1-Lipschitz condition of the activation function in our norm. Begin by noting that most used activation functions are 1-Lipschitz with respect to the standard absolute value, then if we assume that the norm is monotone, i.e. x N ≤ y N if x i ≤ y i for all i, the activation function becomes 1-Lipschitz in the norm ⋅ N . For the theorem below we also assume the unit ball in the norm is a strictly convex set. We get by applying Theorem 1 (in the form of Corollary 1.5 in Gouëzel and Karlsson (2020) ): Theorem 5 Let (X = R N , ⋅ N ) be a normed vector space which has the above monotonicity property and strictly convex unit ball. Consider a stationary sequence of layer maps T n of the form T (x) = W T σ(W x + b), W N ≤ 1, b ∈ X, and σ is 1-Lipschitz when applied componentwise in (X = R N , ⋅ N ). Then as n → ∞ it holds that a.s. there exists a vector v such that The vector v is a priori random but independent of the initial data x 0 . The norm of v is deterministic.
The above theorem is a consequence of the same theorem that gave rise to Theorem 4, but in this case, since we have a norm we get that the metric functional reduces to a dotproduct (Theorem 8) and from this fact we can read off the explicit convergence in the above theorem, see Karlsson (2019) for more details.

An example of the reverse order
Let Ω = [−1, 1] N and use TanH which map the whole vector space diffeomorphically onto the open cube. Let X be the set of distance functions on Ω bi-Lipschitz equivalent to the original distance d 0 defined by a norm ⋅ . The metric D on X is: which was discussed in Section 5, see also Appendix A.3 for more details about the corresponding metric functionals. We consider maps T of the usual type except for insisting on that the matrices W are invertible and also having fixed the activation function TanH so that T ∶ Ω → Ω and which will then be a diffeomorphism, and as remarked in Section 5, leaving the distance of the metric space (X, D) invariant for the induced action T * .
We consider the reverse dynamics T n T n−1 ...T 0 x 0 , and shift the point of view by instead studying d n ∶= T * 1 T * 2 ...T * n d 0 . In the above we see that the maps are "inserted" just before d 0 , which is again the order which corresponds to random walks.
Thanks to the subadditive ergodic theorem and the other theorems in Gouëzel and Karlsson (2020) T * 1 T * 2 ...T * n d 0 will have some regular behavior when n → ∞ especially in terms of metric functionals on the space X. We have the following result proven in Appendix A.3.
Theorem 6 Under the above assumptions there is a number λ so that for all sufficiently large i.
The second assertion means in words that there is a random point x ∈ Ω and points approaching x which the maps T n T n−1 ...T 1 separate with maximal exponential rate.

Dynamics of decision functions
Let Ω ⊂ R N be a compact set. We consider the dynamics T n T n−1 ...T 1 x for x ∈ Ω but shift the point of view to study instead The maps are chosen in a stationary way as before. They preserve our Jacobi distortion metric D, from Section 5. It is then a standard fact that d(f, f n ) is a subadditive process. The subadditive ergodic theorem applies and gives since J f is bounded and bounded away from 0: Theorem 7 In this situation there is a well-defined exponential growth rate λ of the distortion of the decision functions f n (x) = f (T n T n−1 ...T 1 x), more precisely, Via the theory of random dynamical systems as exposed in Arnold (1995), there is an approach to the last theorem via Oseledets' theorem, see also Li (2018) for comparison.

Short time (layer) behavior for random weight initialization
When training deep neural networks an important aspect is how to do the random weight initialization such that we get a network that can actually be trained. In this section we will explore this concept a bit as it relates to our random layer transformations in this paper. However, in contrast to the previous theory we will study the "short time" behavior.
We will consider neural networks of the following simple type where W i is i.i.d. from some distribution and X 0 is some starting point of the network. If we consider this as a Markov chain, i.e. for a fixed point we would take random weights at each step and consider the distribution of the output for a fixed X 0 . We will view this from the context of mixing and as such we need to frame our discussion with some terminology.
Consider a Markov chain on a domain of size n (could be a graph or group for instance) and let P t n (x, ⋅) be the distribution of the Markov chain started at x at time t. Suppose that the Markov chain has a stationary distribution π n . It is well known that if the Markov chain is irreducible and aperiodic we get exponential convergence, i.e. we get max x P t n (x, ⋅) − π n T V ≤ e −ct for some constant c > 0. Here ⋅ T V is the total variation (TV) distance, which is defined for measures µ, ν on Ω (finite state-space Ω) If we define d n (t) ∶= max x P t n (x, ⋅) − π n T V , then we say that the Markov chain exhibits a cut-off at t n with window w n if w n = o(t n ), and Intuitively speaking, this means that d n is close to 1 for times just below t n and d n is close to 0 for times slightly larger than t n , at least for large values of n. Note: the mixing time for the Markov chain will be close to t n for large n. The mixing time for a Markov chain is defined as The cut-off phenomenon is stronger than the concept of fast mixing as it is a double sided property.

Neural network induced Markov chains
In the examples that we will simulate below, the limiting distribution is actually the pointmass at 0, and to make the total variation distance easier to define we work with finite precision, which makes the state-space finite. Note that if we have two measures µ and ν on a finite set Ω then, i.e. the total variation distance is equivalent to the L 1 distance of the densities, which is easier to compute. We now come to our first example, namely a fully connected neural network with TanH activation and revisit the study done in Glorot and Bengio (2010). Consider the following simple Markov chain of neural network type (with heuristic initialization, see Glorot and Bengio (2010)) where , and the TanH is applied componentwise (as is customary). Above we can think of N as the "size" of the Markov chain in the sense above. The result of the simulation can be found in Fig. 2, where we worked with a finite precision of 0.001 and measure the total variation distance to the point-mass at 0. With the heuristic we see that they exhibit a cut-off at pretty much the same level. The cut-off implies that the behavior of this random initialization is markedly different for a layer count of around 3 to layer counts above 10. It seems that this phenomenon occurs even for asymmetric activation functions, like the Sigmoid-weighted Linear Unit (SiLU or Swish) (Ramachandran et al. (2017); Elfwing et al. (2018)) with the same setup as in (7) with the above activation, see Fig. 3. It does not however seem to occur for non-smooth activations, like ReLU.

Conclusion and outlook
We have shown that some aspect of the understanding of deep learning networks have a very natural dynamical interpretation, where recent ergodic theorems can be applied. Indeed the tools are quite general and therefore there is a wealth of possibilities. In other mathematical contexts this versatility has already been demonstrated.
In the context of deep learning, one should translate the meaning of the metrics and their functionals (say in terms of notions of complexity). This we have achieved for several choices of metrics.
A question that arises from the cut-off phenomenon that we demonstrate experimentally is its relevance for training of the network, that is, what difference it makes in practice from choosing fewer layers than the cut-off depth vis-à-vis choosing more layers. In fact, the fast convergence towards the point mass at 0 hints that the last layers in a deep network will have an activation close to 0, which is the linear regime of the activation function, implying that the deeper layers are basically linear mappings. Furthermore, in Glorot and Bengio (2010) they considered instead the normalization which in our case becomes (as the input is the same as the output dimension) which actually only delays the cut-off to higher layer counts, it is however still there. One could speculate that the variance of the initialization can as such be used to control how nonlinear the initialized neural network is.
We believe that the metric setting will in forthcoming work have other interests in deep learning, not only from the application of the non-commutative ergodic theorem. This could ultimately inform the choice of best design of the neural network for a given practical task.

Appendix A. Metric functionals
The mathematical abstraction of distance is that of a metric space X which is a set with a distance function d(x, y) that is symmetric, positive and zero if and only if x = y. Moreover there is the fundamental triangle inequality: the distance between x and y cannot be larger than the sum of the distances from x to z and from z to y, for any point z. Sometimes it is useful and natural to relax the condition of symmetry.
We will now define the metric space analogs of linear functionals, affine hyperplanes and half spaces. Let (X, d) denote a metric space, fix x 0 ∈ X. Let F (X, R) be the space of continuous functions X → R equipped with the topology of pointwise convergence. We define the continuous injection The functions h x are all non-expansive with respect to d and vanish at x 0 . The image Φ(X) can be identified with a subset of a product of compact intervals, which is compact by Tychonoff's theorem. The closure of the image Φ(X) will therefore be compact (similar to the compactness in the weak topology of functional analysis). See for example Gaubert and Vigeral (2012) or Karlsson (2019) for details. We will call the elements in this compact space metric functionals. In particular, to each point x there is the corresponding metric functional h x . For metric functionals that are genuine limits, their level-sets are called horospheres, and sublevel sets are called horoballs. These two concepts are the metric analogs of affine hyperplanes and half-spaces in the linear vector space setting.
The first metric space to look at is the the finite dimensional euclidean space, where the metric is given by d(x, y) = x − y where the norm comes from a scalar product. In this case the metric functionals are up to a constant: the distance to a point in X (in which case sublevel sets are balls) or linear functionals of norm 1 (in which case sublevel sets are half-spaces). Horospheres and horoballs are affine hyperplanes and half-spaces respectively.

A.1 Metric functionals in the case of smooth norms
Below we provide a characterization of the metric functionals in case of norms. For another proof for p-norms see Gutiérrez (2019).
Proposition 8 Let ⋅ a be a norm on R N that is C 2 as a function on the corresponding unit sphere. Consider the function h y n (x) = y n − x a − y n a where y n a → ∞ as n → ∞. Then there is a subsequence and a vector w with w a = 1 such that Proof Begin by first noting that w n = y n y n a is a vector on the unit sphere and as such there is a subsequence of {w n } converging to a vector w s.t. w a = 1. We will dispense with notation for subsequences for simplicity. Let us rewrite h y n (x) = y n − x a − y n a = w n − x y n a a − w n a 1 y n a Taylor expanding the norm ⋅ a around w n z a = w n a + (z − w n ) ⋅ ∇ ⋅ a w + f n (z) z − w n 2 where f n (z) → 0 as z → w n , and ⋅ 2 is the standard Euclidean norm. For simplicity let us relabel our sequence such that y n a = n, then Together with a diagonal argument it is now clear that the C 2 regularity of ⋅ a gives us the limit as n → ∞ (for a subsequence)

A.2 Metric functionals for the Thompson metric
In the following we make the identification of a vector x ∈ R m + with a positive function x ∶ I = {1, . . . , m} → R + . For example, 1(i) = 1 for all i. Consider the following d 1 (x, y) = log sup I x y we wish to derive the limit of where d(1, y n ) → ∞ as n → ∞. Consider the following satisfies 0 < u n ≤ 1 and sup I u n = 1. Therefore there is a subsequence of u n that converges (since I is finite) to u and we have that the same subsequence satisfies The other part of the Thompson metric satisfies a similar relation, i.e. let d 2 (x, y) = log sup I y x we wish to derive the limit of where d(1, y n ) → ∞ as n → ∞. Consider the following y n e sup I log(yn) satisfies 0 < v n ≤ 1 and sup I v n = 1. Therefore there is a subsequence of v n that converges to v (since I is finite) and we have that the same subsequence satisfies This discussion can be compared with a similar one in Gutiérrez (2019). We summarize everything in the following proposition: Proposition 9 The metric functionals of the either half of the (or the full metric) Thompson metric that arise as limits (also called horofunctions) are given as follows: For d 1 we get that there exists a non-zero function u ∶ I → [0, 1] such that where uv = 0 and sup I max{u, v} = 1.

A.2.1 Extension of the ideas to infinite dimensional spaces
Identifying the metric functionals in cases of infinite dimensional spaces is more subtle, see for example Gutiérrez (2020). Especially for the L ∞ space. We will take a look at a special case when we can actually determine the boundary for the Thompson version of the distortion metric.
We choose again as basepoint in our function space the identity function I(x) = x. Note that d(I, g) = log( g ′ ) ∞ .
Lemma 10 Consider the Thompson version of the distortion metrics used above, then if g n is s sequence of C 2 functions such that d(I, g n ) → ∞, satisfying the following differential relation for some C 0 > 0 independent of n, then there exists functions u, v such that there is a subsequence that converges as Furthermore the functions u, v are Lipschitz with constant C 0 such that sup I max{u, v} = 1.
Proof First note that , then u n , v n ≤ e ± log( g ′ n ) exp(d(I, g n )) ≤ 1.
This implies that From this we get that there is a subsequence of u n , v n that converges uniformly to u ∞ , v ∞ which are Lipschitz with constant C 0 . Furthermore, sup I max{u ∞ , v ∞ } = 1.
Remark 11 Actually if we see the above proof, then the only thing we need is to make sure that u ′ n , v ′ n is uniformly continuous. This follows for instance if the modulus of continuity ω of g ′ is bounded by g ′ .

A.3 A Thompson metric for distance functions: Proof of Theorem 6
Let Ω be a compact subset of a finite dimensional vector space with a norm ⋅ . Let us consider the space X of metrics on Ω which are bi-Lipschitz equivalent to d 0 (x, y) ∶= x − y . Specifically this means that d ∈ X iff there exists a constant C > 1 such that On the space X we can consider a Thompson type metric, defined as D(d 1 , d 2 ) = log max sup x≠y d 1 (x, y) d 2 (x, y) , sup x≠y d 2 (x, y) d 1 (x, y) , d 1 , d 2 ∈ X.
As such, we see that the mapping F is an isometric mapping of X into L ∞ (Ω × Ω) with respect to the canonical metric on the Banach space L ∞ (Ω × Ω). Note also, again since the L ∞ -norm does not change on a null set, that we may write where p(f ) is the hemi-norm (cf. Gaubert and Vigeral (2012)) where e z is the evaluation functional e z (f ) = f (z). In the case where f is continuous on Ω × Ω ∖ {x = y} we can write p(f ) = sup z∈Ω×Ω∖{x=y} e z (f ).
Now we introduce layer maps. More precisely, we consider maps T ∶ Ω → Ω which are injective. As explained above these induce non-expansive maps in the metric D: (T * d)(x, y) ∶= d(T x, T y).
To any mapping U ∶ X → X there is a corresponding map U F(d) = F(U d), and, due to the isometry property of F, a non-expansive mapping on X becomes a non-expansive mapping on Y . We take as usual a stationary sequence of such layer maps T n and denote by f n = F(T n ...T 1 ) * (d 0 ), where d 0 denotes the metric coming from the initial norm. Note that f 0 = Fd 0 = 0.
We note that a(0, n) = p(f n −f 0 ) = p(f n ) is a subadditive process, or subadditive cocycle in the terminology of Gouëzel and Karlsson (2020) (hemi-metrics work the same since only the triangle inequality and the non-expansiveness is used). By the subadditive ergodic theorem there is a number λ such that lim n→∞ 1 n p(f n ) = λ.
Moreover, (Gouëzel and Karlsson, 2020, Theorem 1.1) asserts that for any decreasing positive sequence δ n → 0 there are times n i → ∞ such that for every i and n < n i p(f n i − f n ) − p(f n i ) ≤ −n(λ − δ n ) By compactness we may moreover assume that h n i (g) = p(f n i − g) − p(f n i ) converges to a metric functional h. We now follow a similar reasoning to (Gaubert and Vigeral, 2012, p. 349). From the continuity off the diagonal for elements in Y , we see that, given f, g ∈ Y and δ > 0 there is an off-diagonal pointẑ = (x, y) independent of g such that Let z i be the off-diagonal points from (9) corresponding to h n i in the inequality above now with δ n i . By again passing to a subsequence we can ensure that the corresponding sequence of points z i converges to a point z thanks to compactness of Ω × Ω and δ i → 0. We now end up with two cases, either the limit point z is on the diagonal or it is off diagonal. Let us begin with the off-diagonal case: If z = (x, y) is off-diagonal, then (9) gives that h(g) ≥ −e z (g).
This implies in view of the multiplicative ergodic theorem in Gouëzel and Karlsson (2020) that lim n→∞ 1 n f n (z) = λ, and more concretely, lim n→∞ d n (x, y) 1 n = e λ .
Since d n (x, y) = (T n ...T 1 ) * (d 0 )(x, y) = T n ...T 1 x − T n ...T 1 y and Ω is bounded in d 0 , we can only have this conclusion in case λ = 0. In the second case, when z = (x, x) is on the diagonal, then in the notation z i = (x i , y i ) we get from above on the one hand, for fixed f n and all n i > n p(f n i − f n ) − p(f n i ) ≥ −e z i (f n ) − δ n and on the other hand This implies that −n(λ − δ n ) ≥ − log d n (x i , y i ) + log x i − y i − δ n d n (x i , y i ) ≥ x i − y i e n(λ−δn(1+1 n)) Choose , then choose N s.t. δ N (1 + 1 N ) < , then for n i > n > N we get d n (x i , y i ) ≥ x i − y i e n(λ−δn(1+1 n)) ≥ x i − y i e n(λ− ) .
In words this means that there are sequences of points x i → x and y i → x which realize the growth rate of the Lipschitz constant, or put even more strikingly, there is a point x ∈ Ω such that nearby points are separated by the maximum amount (λ) by the maps T n T n−1 ...T 1 .