A topological description of loss surfaces based on Betti Numbers

In the context of deep learning models, attention has recently been paid to studying the surface of the loss function in order to better understand training with methods based on gradient descent. This search for an appropriate description, both analytical and topological, has led to numerous efforts to identify spurious minima and characterize gradient dynamics. Our work aims to contribute to this field by providing a topological measure to evaluate loss complexity in the case of multilayer neural networks. We compare deep and shallow architectures with common sigmoidal activation functions by deriving upper and lower bounds on the complexity of their loss function and revealing how that complexity is influenced by the number of hidden units, training models, and the activation function used. Additionally, we found that certain variations in the loss function or model architecture, such as adding an $\ell_2$ regularization term or implementing skip connections in a feedforward network, do not affect loss topology in specific cases.


Introduction
In recent years, the investigation into the theoretical foundations of Machine Learning (ML) and Deep Learning (DL) models has gained more and more attention as the research community has decided to delve deeper into the reasons why these models can achieve exceptional performance in different application fields [20,30,21,9,27].On the one hand, as the automated decisions provided by these algorithms can have a relevant impact on people's lives, their behavior has to be aligned with the values and principles of individuals and society.This demands designing automated methods we can trust, fulfilling the requirements of fairness, robustness, privacy, and explainability [26].On the other hand, a wide range of tools arose from different areas have been taken into account to give proper explanations to the behavior of ML and DL models according to different mathematical aspects, such as the gradient descent dynamics [23] [34] [13], the role of the activation functions [28], and the importance of the number of layers [4].From the theoretical point of view, along with the aforementioned features, the characterization of the loss function to be minimized is a crucial aspect, as the whole training efficiency relies on its shape, which in turn depends on the network architecture.Several works have already dealt with the analysis of the surface of the loss function, identifying conditions for the presence (or absence) of spurious valleys in a theoretical [32] or empirical-driven way [29], pointing out the role of saddle points in slowing down the learning [8], and giving hints on the topological structure of the loss for networks with different types of activation functions [10,25].
Our contribution fits into the latter line of research, as we give a characterization of the complexity of loss functions based on a topological argumentation.More precisely, given a layered neural network N and a loss function L N computed on some training data, we will measure the complexity of L N by the topological complexity of the set S N = {θ |L N (θ ) ≤ c}.Such an approach is natural, since S N , observed at each level c, provides the form of the loss function: for example, if L N has k isolated minima, then S N has k disconnected regions for some small c.
In the paper, we will provide a bound on the sum of Betti numbers [5] of the set S N .In algebraic topology, Betti numbers are exploited to distinguish spaces with different topological properties.More precisely, for any subset S ⊂ R n , there exist n Betti numbers b i (S), 0 ≤ i ≤ n − 1. Intuitively, the first Betti number b 0 (S) is the number of connected components of the set S that, in the case of S = S N , corresponds to the number of basins of attraction of the loss function.The i-th Betti number b i (S) counts the number of (i + 1)-dimensional holes in S, which provides a measure of the complexity of the error function on a given level.
The upper bound is derived for feedforward neural networks with different numbers of layers, number of neurons per layer, and number of training samples.Moreover, we consider networks with skip connections, such as ResNet.We consider Binary Cross Entropy (BCE) and Mean Squared Error (MSE) loss functions with or without regularization.Finally, we treat networks with Pfaffian activation functions.The class of Pfaffian maps is broad and includes most of the functions, with continuous derivatives, commonly used in Engineering and Computer Science applications, such as the hyperbolic tangent, the logistic sigmoid, polynomials and their compositions 1 .Most of the elementary functions are Pfaffian, for example, the exponential and trigonometric functions.The concept of a Pfaffian function was first introduced in [18], where an analog of Bezout's theorem was proved.Bezout's classic theorem states that the number of complex solutions of a set of polynomial equations can be estimated based on their degree (to be precise, it is equal to the product of their degree).The analog of this theorem proposed in [18] holds for some classes of real and transcendental equations: for a wide class of real transcendental equations (including all real algebraic ones), the number of solutions of a set of k such equations in k real unknowns is finite, and can be explicitly estimated in terms of the "complexity" of the equations.In the Pfaffian setting, Gabrielov and Vorobjov introduced a suitable notion of complexity or format [12].We will define these concepts formally later in the Preliminaries section.
It is worth mentioning that this work takes inspiration from [4], where a similar topological argumentation has been used to study the complexity of the functions realized by a neural network, showing that deep architectures can implement more complex functions than shallow ones, using the same number of parameters.Thus, intuitively, while the results in [4] are about the network function, namely what a network can do, the results in this paper are about the error function, namely how hard the optimization problem is.
In this work, we attempt to provide an answer to the following questions: 1. Can a topological measure effectively assess the complexity of the loss implemented by layered neural networks?2. How do the complexity bounds of deep and shallow neural architectures relate to the number of hidden units and the selected activation function?

Our contribution
This work paves the way toward a more comprehensive understanding of the landscape of loss functions in deep learning models.The sum of Betti numbers of the sublevel sets of the loss function is used to measure the complexity of the empirical risk landscape.More precisely, we derive upper bounds on the complexity of empirical risk for deep and shallow neural architectures employing the theory of Pfaffian functions.This study illuminates the dependence of the error surface complexity on crucial factors such as the number of hidden units, the number of training samples, and the specific choice of the activation function.
Our main contributions are summarized below.
• We derive the Pfaffian format of common loss functions, i.e., the Mean Square Error (MSE) loss function and the Binary Cross-Entropy (BCE) loss function, when training feedforward networks; the Pfaffian format is computed with respect to the weights and involves the knowledge of the Pfaffian format of Pfaffian activation functions.
• Consequently, bounds on the complexity of such loss functions are found in terms of Betti numbers's characterization; multiple bounds are described in terms of the different parameters of the problem (i.e., number of layers, number of neurons per layer, training set size, and total number of learnable parameters).Specifically, we show (coherently with the literature and common knowledge) that the complexity of the loss function increases super-exponentially with the number of layers or neurons per layer and exponentially with the number of training samples.
• We prove that adding a ℓ 2 regularization term to the loss function does not influence its topological complexity under our theoretical analysis.
• Moreover, in our study, we demonstrate that incorporating skip connections (as in ResNets [16]) into the network does not affect the Betti numbers' bounds.
The paper is organized as follows.In Section 2, we briefly review the literature on the characterization of the loss surface and the topological tools used to evaluate the computational power and generalization ability of feedforward networks.In Section 3, some notations and preliminary definitions are introduced, while in Section 4, the main results proposed in this paper are presented.To ensure easy text reading, which allows one to grasp its main contents, all proofs are collected in the Appendix.Finally, some conclusions and future perspectives are reported in Section 5.

Related Work
The characterization of the loss landscape has gained more and more attention in the last few years; attempts to provide a satisfying description have been made through several approaches.In [6,7], the spin-glass theory is exploited to quantify, in probability, the presence of local minima and saddle points.Unfortunately, the connection between the loss function of neural networks and the Hamiltonian of the spherical spin-glass models relies on a number of possibly unrealistic assumptions, yet the empirical evidence suggests that it may exist also under mild conditions.In [8], a method that can rapidly escape high dimensional saddle points, unlike gradient descent and quasi-Newton methods, is proposed.Based on results from statistical physics, random matrix theory, neural network theory, and empirical evidence, it is argued that the major difficulty in using local optimization methods originates from the proliferation of saddle points, instead of local minima, especially in high dimensional problems of practical interest.Saddle points, in fact, are surrounded by plateaus that can dramatically slow down the learning process.In [33], the topological property of the loss function defined as presence or absence of spurious valleys (i.e., local minima) is addressed for one-hidden layer neural networks, providing the following contributions: 1) the Empirical Risk Minimization loss for any continuous activation function and the Expected Value loss with polynomial activations do not exhibit spurious valleys as long as the network is sufficiently over-parametrized; 2) for non-polynomial and non-negative activations, for any hidden width, there exists a data distribution that produces spurious valleys (with non-zero dimension), whose value is arbitrarily far from that of the global minimum; 3) finally, drawing on connections with random feature expansions, even if spurious valleys may appear in general their measure decreases as their width increases.This holds up to a low energy threshold, approaching the global minimum at a speed inversely proportional to the size of the hidden layer.
Based on computer-driven empirical proof, similar results on the characterization of the loss surface in terms of the presence of spurious valleys are also reported in [29].In [11], the loss surface is studied in terms of level sets, and it is shown that the landscape of the loss functions of deep networks with linear activation functions is significantly different from that exploiting half-rectified ones: in the absence of nonlinearities, the level sets are connected, while, in the half-rectified case, the topology is intrinsically different and clearly dependent on the interplay between data distribution and model architecture.Finally, a comprehensive research survey focused on analyzing the loss landscape can be found in [3].
In algebraic topology, Betti numbers are used to distinguish spaces with different topological properties.Betti numbers have been exploited either to give a topological description of the complexity of the function implemented by neural networks with Pfaffian activation functions or to describe their generalization capabilities.More specifically, in [17], by such a technique, bounds on the VC dimension of feedforward neural networks are provided; this work has been later extended to Recurrent and Graph Neural Networks [31].In [4], bounds on the sum of Betti numbers are provided in order to describe the complexity of the map implemented by feedforward networks with Pfaffian activation functions.In [24], the relative efficacy of ReLUs over traditional sigmoidal activations is justified based on the different speeds with which they change the topology of a dataset -as it passes through the layers of a well-trained neural network2 -representing two classes of objects in a binary classification problem.This dataset is viewed as a combination of two components: the first component represents the topological manifold of elements from the first class, and the second component encompasses the elements from the second class.A ReLU-activated neural network (neither a homeomorphism nor Pfaffian) can sharply reduce Betti numbers of the two components, but not a sigmoidalactivated one (which is a homomorphism).Reducing the Betti numbers means that the neural network simplifies the structure of the dataset by reducing the number of connected components, holes, or voids within the data manifold.This reduction suggests that the network is indeed simplifying or transforming the dataset topology, making it more amenable for analysis and classification.Finally, this research suggests that, when dealing with higher topological complexity data (meaning the data has more intricate or complex shapes and relationships), we need neural networks with greater depth (more layers) to adequately capture and understand these complexities.

Preliminaries
In this section, we introduce the notation, basic concepts, and definitions, which will be functional to the subsequent description of the main results.In the following, we will deal exclusively with feedforward neural networks, whose definition is introduced as follows.
Feedforward neural networks -Let θ = { W 1 , b 1 , . . ., W L , b L } be the set of the trainable network parameters, where W l ∈ R n l ×n l−1 , b l ∈ R n l ×1 , l = 1, . . ., L identifies each layer, and n 0 , . . ., n L ∈ N denote the number of neurons per layer.In the following, we assume, without loss of generality, that the network has a single output, i.e., n L = 1.Note that the last assumption is unnecessary to demonstrate the Pfaffian nature of the loss function.However, its inclusion significantly simplifies the subsequent calculations involved in the analysis.The total number of parameters Let x ∈ R n 0 be the input to the neural network.The function implemented by the layered network is , where σ is the hidden layer activation function and g is the activation function of the output neuron.
To simplify the notation, we will aggregate the weights and bias from the same layer into a single matrix, the augmented weight matrix W l = [b l , W l ]; moreover, we will denote by z l the output of the l-th layer and by a l the neuron activations at the same layer.Thus, we have Loss functions -Let D = (x i , y i ) m i=1 be a set of training data, with x i ∈ R n 0 and y i ∈ R. Let L be a generic loss to be minimized over the parameters θ .The empirical risk of loss (or cost) function is defined as the average of the per-sample contributions, where each sample contribution is a measure of the error between the network output and the target value for that sample: being y i the target for the i-the pattern x i .In this work we will study the topological complexity of the landscape of the Mean Square Error (MSE) and Binary Cross-Entropy (BCE) loss functions, which are defined as In the following, we will remove the dependency on the dataset D in the notation of empirical risk.We will focus solely on its reliance on the network parameters θ .Indeed, we want to study the topological complexity of the sublevel set of the empirical risk as a function of the parameters of the network, considering the dataset samples as fixed.Unless specified otherwise, the notation L (θ ) in the following will represent the empirical risk corresponding to the loss function L applied to a dataset containing m pairs (x i , y i ).In general, we consider the targets to be real numbers.
Notice that since we're computing the topological complexity of the empirical risk, the complexity obtained using the Pfaffian format will also depend on the number of samples in D. However, for classification problems where the Binary Cross-Entropy (BCE) loss is used, each target y i is either 0 or 1.
Moreover, we consider a regularized form for the objective function that can be expressed as where Ω(θ ) is a regularization term, for instance, Ω(θ ) = 1 2 w 2 2 (ℓ 2 regularization norm).
Pfaffian Functions -Pfaffian functions [19] are analytic functions satisfying triangular systems of first order partial differential equations with polynomial coefficients.For this kind of functions, an analogous of the Bézout theorem holds.The classical Bézout theorem states that the number of complex solutions of a set of k polynomial equations in k unknowns can be estimated in terms of their degrees (it equals the product of the degrees).
For a wide class of real transcendental equations (including all real algebraic ones) the number of solutions of a set of k such equations in k real unknowns is finite and can be explicitly estimated in terms of the " complexity" of the equations, which leads to the version of Bézout theorem for Pfaffian curves and Pfaffian manifold [19].
The class of Pfaffian functions includes a wide variety of known functions, e.g. the elementary functions, including exponential, logarithm, tangent, and their combinations [12].Interestingly, many common activation functions used in neural networks, such as the sigmoid function and hyperbolic tangent, can be classified as Pfaffian functions.
Intuitively, a function is Pfaffian if its derivatives can be defined in terms of polynomials of the original function and/or a chain of other Pfaffian functions.Formally, we can state the following definition.
Here, P i j (x, y 1 , . . ., y i ) are polynomials in the n+i variables x 1 , . . ., x n , y 1 , . . ., y i of degree not exceeding α.Definition 3.2.Let ( f 1 , . . ., f ℓ ) be a Pfaffian chain of length ℓ and degree α, and let U be its domain.A function f defined on U is called a Pfaffian function of degree β in the chain ( f 1 , . . ., f ℓ ) if there exists a polynomial P in n + ℓ variables, of degree at most β , such that f (x) = P(x, f 1 (x), . . ., f ℓ (x)), ∀x ∈ U.The triple (α, β , ℓ) is called the format of f .
The polynomial P i j itself may explicitly depend on x.Moreover, even if P i j does not have a direct dependence on x, it can still depend on x indirectly through the function f 1 (x).We say that the polynomial P i j depends directly on x if there are occurrences of x that are not of the type f i (x).For example, consider the function f (x) = arctan(x), which falls into the second category of functions described above since it can be represented by the chain ( f 1 , f 2 ), where 2 , with P 2 that explicitly depend on x.On the other hand, the tanh function is a Pfaffian function falling under the first category.It can be represented by the chain containing only f 1 (x) = tanh(x), and 2 .In this case, there is no explicit dependence on x in the polynomial P 1 .This distinction will be crucial to assess the right computations in the statement of Theorem 4.1.
Let us now introduce the notion of Pfaffian variety and semi-Pfaffian variety.Definition 3.3.The set V ⊂ U is a Pfaffian variety if there are Pfaffian functions p 1 , . . ., p r in the chain

A basic semi-variety S on the variety V is a subset of V defined by a set of sign conditions (inequalities or equalities) based on the Pfaffian functions p
, where ε 1 , . . . ,ε s are any comparison operator among {<; >; ≤, ≥; =}.
As outlined in the Introduction, our focus in this work is directed towards exploring the complexity of the topological space defined by the sublevel set of the empirical risk related to the loss function L , namely S = {θ : L (θ ) ≤ c}.This set represents the collection of parameter values θ for which the empirical risk of the loss function is less than or equal to a constant c.When the empirical risk of the loss function is a Pfaffian function with respect to the parameter of the network, this set is exactly a Pfaffian semi-variety.Level curves or basins of attractions can be often described in terms of Pfaffian varieties, whose complexity can be measured through the characterization of their Betti numbers [4] or counting directly the number of connected components [12].
Betti Numbers -Betti numbers are topological objects that can be used to describe the complexity of topological spaces.More formally, the i-th Betti number of a space X is defined as the rank of the (finitely generated) i-th singular homology group of X. Roughly speaking, it counts the number of i-th dimensional holes of a space X3 and captures a topological notion of complexity that can be used to compare subspaces of R d .The reader can refer to algebraic topology textbooks for a more comprehensive introduction to homology [5,15].
Informally, Betti numbers quantify the number of "holes" of various dimensions in a topological space.Each Betti number, b i , represents the number of i-dimensional 'independent' holes or cycles that cannot be continuously deformed into each other.For instance, the 0-th Betti number, b 0 , counts the number of connected components in the space.The first Betti number, b 1 , counts the number of independent loops or one-dimensional holes.Higher Betti numbers, such as b 2 , b 3 , and so on, count holes of increasing dimensionality.To give some examples, a circle has one connected component (b 0 = 1) and one hole of dimension one (b 1 = 1).On the contrary, a 2-dimensional unit sphere, {x ∈ R 2 : ||x|| 2 = 1}, has one connected component (b 0 = 1) and no holes (b 1 = 0) but has one two-dimensional cavity (b 2 = 1) .A torus, like a doughnut, has one connected component (b 0 = 1) two independent holes (b 1 = 2), and one two-dimensional cavity (b 2 = 1).This distinction can be understood visually: a sphere is a solid shape with no internal holes, while a torus has a hole in its center and an additional loop around the hole.When applied to the context of a loss function, Betti numbers offer insights into the complexity of its loss landscape, such as the presence of multiple local minima and regions of attraction.In other words, Betti numbers can be considered a tool to analyze the configuration of critical points in the optimization function landscape.
The following result connects the theory of Pfaffian functions and Betti numbers; in particular, it gives a bound on the Betti numbers for varieties defined by equations, including Pfaffian functions.Theorem 3.5.[Sum of the Betti numbers for a Pfaffian variety [35]] Let S be a compact semi-Pfaffian variety in U ⊂ R ñ, given on a compact Pfaffian variety V , of dimension n ′ , defined by s sign conditions of Pfaffian functions.If all the functions defining S have complexity at most (α, β , ℓ), then the sum of the Betti numbers of S is In this paper, the theorem is applied on the Pfaffian variety S N = {θ ∈ U, s.t.L (θ ) ≤ c}, determined by the unique sign condition L (θ ) ≤ c, for a given threshold c.In this way, we will obtain a bound on the sum of the Betti numbers of S N .Therefore, we have to demonstrate that the loss function is a Pfaffian function and compute its format, a goal that can be achieved by writing the loss derivates in terms of the network parameters and a Pfaffian chain.We will make use of the chain rule of Backpropagation to write the derivatives of the loss function.
The constraints on the compactness of U and V can be removed without affecting the bounds, as shown in [36].In our case, we will consider U = R n , since it represents the domain of the parameters, moreover, given that the semi-Pfaffian variety is defined by a unique sign condition, s = 1.

Main Results
In this section, we present our theoretical analysis on the loss landscape topology.We start proving that, given a Pfaffian activation function σ of format (α σ , β σ , ℓ σ ), the MSE loss function and BCE loss function computed over feedforward neural networks are also Pfaffian functions; their format is provided with an explicit dependency on the format of σ , on the number of layers, and the number of neurons per layer.Theorem 4.1 (MSE Loss).Let σ : R → R be a function for which exists a Pfaffian chain (σ 1 , . . ., σ ℓ ) and ℓ σ + 1 polynomials Q and P i , 1 ≤ i ≤ ℓ σ of degree β σ and α σ , respectively s.t.σ is Pfaffian with format (α σ , β σ , ℓ σ ).
Moreover, let g : R → R be a function for which there exists a Pfaffian chain (g 1 , . . ., g ℓ g ) and ℓ g + 1 polynomials, Q g and P i g , 1 ≤ i ≤ ℓ g of degree β g and α g , respectively, s.t.g is Pfaffian with format (α g , β g , ℓ g ).Let f (θ , x) be the function implemented by a neural network with parameters θ ∈ R ñ, input x ∈ R n 0 , L layers, and an activation function σ for all layers except the last.The last layer can either have an activation function g or be linear.
Then, the MSE Loss function is Pfaffian with format when the last layer is linear.Here, where case 1 refers to the case where P i σ (a, σ 1 (a), . . . ,σ ℓ σ (a)) do not depend explicitly on a, namely occurrences of a appear that are not of the type σ i (a); case 2 refers to the case where they depend on it.Moreover, we assume that the polynomials P i g (a, g 1 (a), . . ., g ℓ g (a)) do not depend explicitly on a.The format of the chain becomes if the nonlinearity g is applied also to the last layer.The definition of degree(g ′ ) is analogous to that of degree(σ ′ ).
For the BCE Loss function, we only explore the case where the last layer contains a non-linearity, namely f θ (x) = g(a L ) since BCE loss is commonly used in binary classification problems where the output is a probability of the input belonging to one of two classes.In such problems, the last layer of the model typically uses a sigmoidal activation function to ensure that the output is between 0 and 1, representing the probability of the input belonging to a certain class.

If the last activation function is the sigmoid function, the BCE Loss function has the format
Theorems 4.1 and 4.2 hold in general for any Pfaffian activation function and for any sequence layer widths (n 0 , n 1 , . . ., n L ).
In the following, we present the outcomes for the particular scenario in which the activation function of the intermediate layers is either a sigmoid or a hyperbolic tangent.Additionally, for the sake of simplicity, we assume that all hidden layers share the same width, denoted as h.

Corollary 4.3. Let us consider a feedforward perceptron network where all hidden layers have the same width h. The activation function of intermediate layers can be either the hyperbolic tangent (tanh) or the sigmoid function (logsig), and the loss function is the Mean Squared Error. In this setting, the following holds:
• when the last layer of the network is linear, the Pfaffian format of the loss function is given by • when the last layer passed through a sigmoid activation function, the Pfaffian format of the loss function is We can state an analogous result for the BCE loss function.

Corollary 4.4. For a feedforward perceptron network where all the hidden layers have the same width h, trained using BCE loss function and a non-linear last layer, the following holds:
• if the non-linearity used is the sigmoid function, the Pfaffian format of the loss function is • if the non-linearity used is tanh(x), the Pfaffian format of the loss function is We now state the main results of our work.
The presented theorem investigates the dependence of the sum of Betti numbers associated with the semi-Pfaffian variety S N , which represents the parameter set where the loss is non-negative, on factors such as the number of samples, network width, and network depth.Using Corollaries 4.3 and 4.4, we can derive the bounds on the Betti numbers of the Pfaffian semi-variety for both MSE and BCE loss functions.• With respect to the number of samples m, fixing h and L as constants,-we have that B(S) ∈ κ , where κ 1 is a constant greater than 2.

• With respect to h, we have B(S) ∈
On the other hand, in the case of a shallow network with one hidden layer, i.e., L = 2, the following results hold.
• With respect to m, the bound is the same we obtained for deep networks, B(S) ∈ κ , where κ 2 is a constant greater than 2.

• With respect to h, we have B(S) ∈ O(h) O(h) .
It is worth emphasizing that the bounds concerning h and L offer an insight into the relationship between the topological complexity of the loss landscape and the total number of parameters ñ.Specifically, in both cases, as ñ varies, by treating h as a variable while keeping L fixed, we explore the effect of changing the network width.Conversely, by treating L as a variable while keeping the width fixed, we investigate the impact of altering the network depth.
A first major remark from Theorem 4.5 is that the upper bound on the Betti numbers associated to the loss function is only exponential in the number of samples m, while it is superexponential in the number of neurons h or in the number of layers L. Intuitively, the take-home message is that the topological complexity of the loss function is less conditioned by the number of samples than by the number of parameters.
As it may not appear surprising, Theorem 4.5 also suggests that the complexity of the loss landscape with respect to deep networks increases with the number of neurons h at a much faster pace than the one with respect to the shallow networks, going from a dependence of the type O(h 2 ) O(h 2 ) to a dependence of the type O(h) O(h) .Such a difference in behavior is coherent with results present in literature [22], where it is proven that, when networks become sufficiently deep, neural loss landscapes quickly move from being nearly convex to being highly chaotic.

Regularization terms and residual connections
The role of regularization Remark 4.6.(ℓ 2 regularization) One could be interested in seeing how the introduction of regularization terms influences our analysis.We can face this new scenario in case we add an ℓ 2 regularization term, being the ℓ 2 regularization term Ω(θ ) = ∑ i Wi 2 polynomial in the parameters θ .This term only affects the term β of the format of the Pfaffian function L (θ ) = L (θ ) + λ Ω(θ ), as it affects the degree of the polynomial with respect to the weights, adding a monomial term of degree 2; nevertheless, the bound on the Betti numbers is not affected by it.This can be easily derived from the computations carried on in the Appendix for the proof of Theorem 4.5.The ℓ 2 regularization does not promote sparsity (which is instead promoted by the ℓ 1 regularization) [14], but it affects the magnitude of the weights.This could suggest that the regularization term may provide a scaling of the loss function, and therefore, all local minima may still be present; nevertheless, it is possible that our theoretical bounds may not be able to catch the influence of the regularization term in the loss landscape.

Residual Connections
Skip connections or residual connections, are widely employed in neural networks to alleviate the vanishing gradient problem and enhance information flow across layers.The ResNet model popularized this architectural design [16] and has since then been adopted in various network architectures.
Remark 4.7.Introducing a residual term at each layer in a neural network, thus creating a Residual Neural Network (ResNet), does not impact the bounds provided in our analysis.It does not affect either the number of functions required in the chain or the maximum degree of the polynomials.The addition of skip connections combines the output of a previous layer with that of a subsequent layer through summation.Regarding our analysis, the essential factors, such as the degree of polynomials and the length of the Pfaffian chain, remain the same.The only change lies in the specific terms to be included within the chain.See section A.6 in the Appendix for more details.Consequently, it implies that utilizing a ResNet rather than a conventional feedforward neural network does not alter the topology of the loss function or its optimization process.Instead, the primary advantage lies in enhancing the network's expressive capacity.
Skip connections allow gradients to flow more easily during backpropagation, facilitating the training of deeper networks.It has been observed that skip connections promote flat minimizers and prevent the transition to chaotic behavior [22].Our current theoretical framework is limited in capturing the reduced complexity of the loss landscape induced by skip connections.Specifically, our theory provides an upper bound on the number of minima, lacking a lower bound, which implies that our estimate may exceed the actual value.Moreover, the analysis in [22] focuses solely on the minima, while our proposed bound encompasses the sum of all non-zero Betti numbers.Finally, it is worth observing that the optimization algorithms do not explore the whole space but only a part where the complexity of the function might be lower.Therefore, regularisation and skip connections could be mechanisms for which only submanifolds are explored by the optimization algorithm, and such behavior could not be captured by what the global bound suggests.

Conclusions
In our investigation, we determined that when employing a Pfaffian non-linearity, both the MSE and BCE loss functions can be represented as Pfaffian functions.Subsequently, we analyzed the respective Pfaffian chains obtained in each case.Specifically, we examined the differences in the complexity and performance of the Pfaffian chains resulting from the use of the two loss functions.
When studying the complexity of the loss landscape, a superexponential dependency on the network parameters has been found; interestingly, a qualitative difference can be highlighted between the shallow and the deep case, as we focus on the impact of the number of neurons h.Indeed, as the number of layers starts to increase, the superexponential dependency involves a term h 2 , and not h anymore.This result is aligned with the general intuition and previous works in literature [4].In any case, the asymptotic analysis shows that the sum of Betti numbers has an exponential dependency on the square of the number of samples m.
It is worth underlying the characterization of the topological complexity we derived for loss functions with an additional ℓ 2 term; from our analysis point of view, it seems that the presence of a regularization term is not implied in the design of the loss landscape, pointing out to a different role of the regularization itself in the network training, e.g. the optimization process.Nevertheless, being those boundaries not tight, space for a deeper analysis is not left out.
Bounds provided by the sum of Betti numbers are evidently not tight; our analysis suggests a qualitative interpretation, more than a quantitative one.Clearly, obtaining a bound on the number of connected components B 0 (S) rather than B(S) would give a more accurate characterization of the topology of the loss landscape; this is a perspective to be considered for future works.
Moreover, it would be interesting to connect our results with the mode connectivity framework, in specific through the lens of Morse theory [1], which provides a characterization of the set of configurations of a neural network with respect to a fixed empirical loss value.Indeed, improving our analysis with Morse theory could help to define the connectivity maps at many dimension levels, leading to a better quantification of each single Betti number.

A Appendix
A.1 Making derivatives explicit using Backpropagation , y i ) be a generic loss.We aim to determine the gradient for a given input-output pair (x i , y i ), with respect to the weight variables w l jk (connecting the j-th neuron of layer l − 1, with the k-th neuron of layer l), which are elements of the augmented weight matrix W l .The gradient components ∂ L ∂ w l jk can be calculated through the chain rule.The Backpropagation algorithm provides an efficient method of spreading the error contribution back through the layers for updating weights.= δ l j z l−1 i , which represents a polynomial function in δ l j , z l−1 i , so that all δ l j , z l−1 i and their derivatives belong to the Pfaffian chain describing L .Moreover, by the chain rule, we have that which means that δ l j is polynomial in all n l+1 , δ l+1 i and σ ′ (a l j ), so that we have also to include all δ l+1 j and all σ ′ (a l j ) and their derivatives in the Pfaffian chain.
Summing up, fixing an input x i , y i and proceeding backward through the layers, we can derive that Remark A.1.Notice that if σ is Pfaffian.It follows that the derivative σ ′ is polynomial in the factor of the chain, and the degree of the polynomial is at most α σ , while the degree of σ in its chain is β σ .

A.2.1 Preliminaries
We want to prove that the MSE loss function and the BCE loss functions are Pfaffian functions with respect to the parameters of the network, in the hypothesis that the non-linearities σ and g are Pfaffian.To do so, we need to find a Pfaffian chain so that the loss function can be written as a polynomial in that chain, and we need to compute the degree of this polynomial in the parameters and the maximum degree of the derivatives of the functions in the chain with respect to the parameters of the network.
Notice that in this particular case of the MSE, meaning that if f is a Pfaffian function of a given format (α f , β f , ℓ f ), the loss is a Pfaffian function with respect to the same chain with format (α f , 2β f , ℓ f ).
In the case of the BCE loss function, always assuming that f is a Pfaffian function of a given format (degree( f ′ ) − 1, β f , ℓ f ) we can consider two possible chains.The first one is the chain in which we add to the chain of f the functions log( f θ (x i )) and log(1 − f θ (x i )) and their derivatives meaning that the format of the chain becomes (max{degree( f ′ ) + 2, α f }, 1, ℓ f + 4), where degree( f ′ ) is the degree of f ′ as polynomial in the chain, we will specify which chain in the various cases.In case we have a sigmoid as the final activation function, we could consider a different chain in which we include the loss in the chain; in this case, as we will see in A.2.3 to obtain a pfaffian chain, we also need to include the function the sigmoid of f , σ ( f (x)) so the format becomes (degree To determine the degree of f ′ we will need to compute the degree of σ ′ .This will be useful for all the different cases considered, so we're doing it in this section.∂ y s has degree β σ − 1 and P u (a, y 1 , . . ., y u ) has degree α σ in σ 1 (a), . . . ,σ ℓ (a).In conclusion dσ (a) da a=a l h is a polynomial of degree β σ + α σ − 1 if, ∀i, P i does not depend directly on a, and it is β σ + α σ − 1 + α σ (β σ + 1) in the general case.
Indeed if P i depends on a, we have that P(a l h , σ 1 (a l h ), . . ., a l h ) has degree α σ (β σ + 1), since the degree of a l h is β σ + 1 in the Pfaffian chain.Notice that a l h = W l σ (a l−1 ) and σ (a l−1 ) has degree β σ .Summarizing : Where case 1 refers to the case where P i σ (a, σ 1 (a), . . . ,σ ℓ σ (a)) don't depend explicitly a and case 2 where they depend on it.

A.2.2 MSE loss function
Proof of Theorem 4.1.In our hypothesis n L = 1, so δ L , a L and f θ (x) are scalars.Depending on whether the last layer is linear or the non-linearity g is applied, we have that Linear last layer In the case of linear activation, given that a L = W L σ (a L−1 ) and that σ is Pfaffian with respect to the chain σ 1 , . . ., σ ℓ σ we obtain that f θ (x) = a L is polynomial in the functions following chain (((σ k (a j i )) k=1,...ℓ σ ) i=1,...,n j ) j=1,...,L−1 The degree of the Pfaffian function f in this chain is β f = β σ + 1 ; the maximum degree of the derivatives depends on the degree of σ ′ in (4) and is given by the chain rule, the worst case is given by deriving of the term of the vector σ (a L−1 ) with respect to one of the weights of the first layer.In this case, applying the chain rule and going backward layer by layer, we obtain that every step, we multiply the weight of one layer and the σ ′ it follows that the degree of Taking into account what was said in Section A.2.1, we obtain that for a single input point, x, we obtained that the MSE loss with linear activation for the last layer is Pfaffian with respect to the following chain of length ℓ σ ∑ L−1 k=1 n k : (((σ k (a j i )) k=1,...ℓ σ ) i=1,...,n j ) j=1,...,L−1 (5) The order of the chain is given, going from the inner cycle to the outer cycle.
Considering that we have to consider all the input points, the length of the chain becomes mℓ σ ∑ L−1 k=1 n k .The format of the chain of the MSE loss function is therefore Non-linear last layer with non-linearity g In this case, we need to add to the chain described in Equation ( 5) the terms (g k (a L )) k=1,...,ℓ g .The final chain will be: The degree of the function f in this chain is given by β g , the maximum degree of the derivatives is the degree of ∂ g(a L ) and is (degree(σ ′ ) + 1)(L − 2) + degree(σ ′ ) + degree(g ′ ) + 1.
Using the argument we used before for σ ′ , we have that the degree of g ′ (a) is β g + α g − 1 if, ∀i, P i g does not depend directly on a, and it is β g + α g − 1 + α g (β g + 1) in the general case.degree(g ′ ) = β g + α g − 1 case 1 β g + α g − 1 + α g (β g + 1) case 2 (8) Summarizing the format of the chain in the case of non-linear activation for the last layer is

A.2.3 BCE loss function
Proof of Theorem 4.2.We study the two cases when the intermediate activation g is the sigmoid and when it is a different function.
Non-linear activation g different from the sigmoid function In this case, the Pfaffian chain for the loss function will be the chain described in 7 to which we add the following terms 1 g(a L ) , log(g(a L )), 1 1−g(a L ) , log(1 − g(a L )).The length of the chain will be ∑ L−1 k=1 n k + ℓ g + 4. The degree of the loss function with respect to this chain is 1, and the maximum degree of the derivatives is given by the degree of the following derivative ∂ 1/g(a L )

Topological description of loss surfaces based on Betti Numbers
It follows that the format of the chain for the BC loss function with sigmoid activation for the last layer is Non-linear activation g is the sigmoid function In this case, we want to include the loss in the chain and use the trick of backpropagation introduced in section A.2.1 to be sure that its derivatives are polynomial in the chain.Eq 2 shows that the derivative of the loss with respect to the parameters is poly in δ L i and in the terms of the chain (7), in this case with g equal to the sigmoid function.
If we consider only a single sample x and the output of the network f θ (x) = g(a L ).We have that If the non-linearity g is the sigmoid function g(x) = 1 1+e −x , the term becomes 1, and we don't need to deal with it and the degree of δ L is the degree of g(a L ), that is β g that for the sigmoid function is 1.We recall that the sigmoid function is Pfaffian with format (2, 1, 1).
It follows that the format of the chain for the BC loss function with sigmoid activation for the last layer is The last +1 in the length is given by the fact that we're also adding the loss function computed on the input dataset to the chain.Moreover, we can compute degree(g ′ ) that is this case is 2, notice that this is smaller than the worst case proposed in (8) that would be equal to 4.
The final format of the chain will be Proof.It is enough to remark that the format of the hyperbolic tangent and the sigmoid function is (α σ , β σ , ℓ σ ) = (2, 1, 1).Substituting these values in Theorem 4.1 leads straightforwardly to the statement.

A.4 Proof of Corollary 4.4
Proof.The result for the hyperbolic tangent activation function can be obtained by applying Theorem 4.2 with its corresponding format of (2, 1, 1).On the other hand, for the sigmoid function, we have that σ ′ (x) = σ (x)(1 − σ (x)).This allows us to obtain a linear dependency on σ (x) in the derivative of the BCE loss function.Indeed, A.5 Proof of Theorem 4.5 Proof.We can use Theorem 3.5 with U = R ñ, with ñ = h(n 0 + 1) the total number of parameters of the network.
In this case the term s n ′ in Equation ( 1) can be ignored since s = 1.
Bounds for MSE loss function: deep case For L ≥ 3: • if the last layer has a linear activation, we have that If h >> m, and we consider L and m as constant it becomes It is important to note that the overparametrized regime falls within this scenario.
• if the last layer has a nonlinear activation, we have that: .Conversely, as a function of h, the dependency changes and we obtain B(S) ∈ O(h) O(h) .
On the other side, if h >> m and we consider m and L as constant, we have that Resulting in asymptotic bounds equal to those derived previously for the MSE loss with non-linear activation.The same holds with similar computations in case the last activation function is the hyperbolic tangent.
We remark that for the BCE loss, our focus is primarily on studying the case where the last layer of the neural network has a non-linear activation function since it is commonly used for binary classification tasks.

A.6 Residual Connections
Without loss of generality, we can consider the case in which we utilize skip connections that provide the previous layer's output, through summation, as an additional input to the subsequent layer.In this case, denoting by z i the output of the i-th layer, if we consider the case, we have that If we want to obtain the derivative of z l with respect to a parameter of the network w k = W k i with k < l and i ∈ {1, . . ., n k }, we have that We observe that the derivative ∂ z l −1 ∂ w k appears twice in the equation.However, due to the multiplication with other terms in the first term, it only affects the degree of the polynomial in the first term of the sum.Therefore, we can disregard the second term in the equation when interested in computing the format of the Pfaffian chain.This reasoning can be extended to all layers, demonstrating that the degrees of the derivatives will remain unchanged, just as we computed for simple feedforward perceptron neural networks.Similarly, the length of the chain remains unaltered.In this case, as well, the functions to be included in the chain are the outputs of the layers, which are exactly the same in number as those in feedforward networks, albeit with different forms.

Theorem 4 . 2 (
BCE Loss).Let the hypothesis of Theorem 4.1 hold.If the activation function g is also used in the last layer, the BCE Loss function is Pfaffian with format

Theorem 4 . 5 .
Let us consider a deep feedforward perceptron network N with L ≥ 3 layers all having width h.The activation function can be either the hyperbolic tangent or the sigmoid function; the loss is either the MSE or the BCE function, and the last layer is either linear (only for MSE) or nonlinear.Moreover, let us denote by S the semi-Pfaffian variety given by the set of parameters where the loss function is non-negative, i.e. S = S N = {θ |L (θ ) ≤ c} for a threshold c ∈ R + .Then, the sum of the Betti numbers B(S) is bounded as follows.

Let us define δ l k = ∂ L ∂ a l k , for l = 1 ,
. . ., L, as the derivative of the cost function with respect to the activation a l k of the k-th neuron of layer l.Then ∂ L ∂ w l i, j