Neural networks (NNs) are central to modern machine learning and achieve state-of-the-art results in many applications. However, the relationship between loss geometry and generalization is still not well understood. The local geometry of the loss function near a critical point is well-approximated by its quadratic form, obtained through a second-order Taylor expansion. The coefficients of the quadratic term correspond to the Hessian matrix, whose eigenspectrum allows us to evaluate the sharpness of the loss at the critical point. Extensive research suggests flat critical points generalize better, while sharp ones lead to higher generalization error. However, sharpness requires the Hessian eigenspectrum, but general matrix characteristic equations have no closed-form solution. Therefore, most existing studies on evaluating loss sharpness rely on numerical approximation methods. Existing closed-form analyses of the eigenspectrum are primarily limited to simplified architectures, such as linear or ReLU-activated networks; consequently, theoretical analysis of smooth nonlinear multilayer neural networks remains limited. Against this background, this study focuses on nonlinear, smooth multilayer neural networks and derives a closed-form upper bound for the maximum eigenvalue of the Hessian with respect to the cross-entropy loss by leveraging the Wolkowicz-Styan bound. Specifically, the derived upper bound is expressed as a function of the affine transformation parameters, hidden layer dimensions, and the degree of orthogonality among the training samples. The primary contribution of this paper is an analytical characterization of loss sharpness in smooth nonlinear multilayer neural networks via a closed-form expression, avoiding explicit numerical eigenspectrum computation. We hope that this work provides a small yet meaningful step toward unraveling the mysteries of deep learning.
Figures & tables
Fig. 1 : The NN architecture analyzed in this study.
Fig. 2 : Relationship between the maximum eigenvalues at various critical points and their respective upper bounds. The eigenvalues are calculated numerically, while the upper bounds are calculated analytically using the main theorem in Eq. ( 7 ). All critical points observed in the experiment ( N=3 ) described in Appendix C are plotted.
Fig. 3 : (Top) Decision boundaries in the input space for the NNs with the first and second largest upper bounds of the maximum eigenvalue λsup(θ) , observed at all critical points ( N=3 ) in the experiments of Appendix C . Data points represent the training data, where white and black indicate Class 0 and Class 1, respectively. (Bottom) One-dimensional visualization of the loss L along the directions of the eigenvectors u1,⋯,u4 .
Fig. 4 : Cases where the upper bound of the maximum eigenvalue, λsup(θ) , ranks first and second smallest. Other descriptions are the same as in Figure 3 .
Fig. 5 : Dynamics of L , λsup(θ) , and λ1 with respect to training epochs for the highest and lowest λsup(θ) cases.
Fig. 6 : Distribution of the maximum eigenvalue upper bounds at critical points. All critical points observed in the experiment ( N=3 ) described in Appendix C were used.
Fig. 7 : Relationship between the maximum eigenvalue upper bound and the Macro F1-score (test data). The boxes represent the 25th–75th percentile range, the whiskers indicate the 10th–90th percentile range, and the thick horizontal lines denote the medians. The p -value was calculated using the two-sided Mann-Whitney U test. Critical points from the experiment ( N=3 ) described in Appendix C were used.
Fig. 8 : Hessian (Matrix size: 13×13 ) of a single critical point obtained in the experiment in Appendix C . The left shows the analytical solution based on Eqs. ( 15 )–( 18 ), and the right shows the numerical solution obtained by the three-point central difference approximation. Thick lines indicate the boundaries of the block components. Top-left: HL(w,w) , top-right: HL(w,v) , bottom-left: HL(v,w) , and bottom-right: HL(v,v) .
Fig. 9 : Comparison of the trace between numerical solutions obtained via “numpy.trace” and analytical solutions derived from Theorems 2 and 5 . All critical points identified in Appendix C are employed.
Fig. 10 : Relationship between the Frobenius norm of the parameters and the upper bound of the maximum eigenvalue. A total of 353 critical points mentioned in Appendix C were utilized ( N=3 ).
Fig. 11 : Relationship between the upper bound of the maximum eigenvalue and the dimensionality of the hidden layer N . The boxes represent the 25–75% range, the whiskers indicate the 10–90% range, and the thick horizontal lines denote the median. The p -value is obtained from the two-sided Mann-Whitney U test.
Fig. 12 : Relationship between the Frobenius norm of the hidden layer and the upper bound of the maximum eigenvalue. The left part shows a scatter plot of all critical points, while the right part provides an enlarged view of the same plot. The critical points used were obtained as described in Appendix C ( N=3 ).
Fig. 13 : Activation function f(y) and its first and second derivatives.
The flatness hypothesis suggests that flatness of the loss landscape, as measured by the eigenvalues of the loss Hessian, correlates with better neural network generalization. While various algorithms reduce these eigenvalues, most focus on procedural design, leaving it unclear how data distributions and NN parameters structurally determine directions toward flat minima. Characterizing these directions analytically is generally intractable. To overcome this mathematical difficulty, recent studies derived the Wolkowicz-Styan (WS) upper bound on the maximum eigenvalue of the cross-entropy loss Hessian in three-layer NNs. Although this upper bound is differentiable, its gradient was not derived. Therefore, we analytically derive the gradient of the WS upper bound to characterize directions leading to flat minima. Based on this, we propose Hessian Spectral Range (HSR) Regularization, which updates parameters along the steepest descent direction of the WS bound. Experiments demonstrate that HSR Regularization narrows the Hessian eigenvalue spectrum, avoids sharp minima and saddle points, and promotes convergence to flat minima. Although the applicability of this method is currently limited to cross-entropy loss and three-layer architectures, to the best of the authors' knowledge, this is the first study to report a closed-form gradient that promotes convergence to flat minima without numerical approximations. Therefore, the theoretical analysis of this gradient is expected to contribute to the further development of NNs.
Yuto Omae, Kazuki Sakai, Yohei Kakimoto +3
Nihon University (Japan) · National Institute of Technology, Nagaoka College (Japan) · Tokyo City University (Japan)
The Hessian matrix is an important quantity of interest when it comes to studying the loss landscape and optimization dynamics in deep learning, as well as designing measures of generalization, second-order learning algorithms, etc. Prior works have focused on empirical results or pursued a theoretical treatment under overly simplified settings. In this work, we derive the eigenvalues of the Hessian of linear networks with arbitrary widths and depths, and datasets with an arbitrary number of samples, features, and labels. Importantly, for classification tasks with MSE loss, we identify that the sharpness of the solution is directly related to the maximum proportion of samples belonging to any class. We empirically validate our predictions and systematically analyze the effects of shedding the impractical assumptions one at a time, as well as incorporating nonlinearities. We observe that our predictions are considerably robust in most cases, allowing us to extend our conclusions to more practical learning setups.
Jasraj Singh, Enea Monzio Compagnoni, Antonio Orvieto
ELLIS Institute, Tübingen, Germany · Universität Basel, Basel, Switzerland · MPI-IS, Tübingen, Germany
Training modern neural networks often relies on large learning rates, operating at the edge of stability, where the optimization dynamics exhibit oscillatory and chaotic behavior. Empirically, this regime often yields improved generalization performance, yet the underlying mechanism remains poorly understood. In this work, we represent stochastic optimizers as random dynamical systems, which often converge to a fractal attractor set (rather than a point) with a smaller intrinsic dimension. Building on this connection and inspired by Lyapunov dimension theory, we introduce a novel notion of dimension, coined the `sharpness dimension', and prove a generalization bound based on this dimension. Our results show that generalization in the chaotic regime depends on the complete Hessian spectrum and the structure of its partial determinants, highlighting a complexity that cannot be captured by the trace or spectral norm considered in prior work. Experiments across various MLPs and transformers validate our theory while also providing new insights into the recently observed phenomenon of grokking.
Mario Tuci, Caner Korkmaz, Umut Şimşekli +1
INRIA, CNRS, Département d’Informatique de l’Ecole Normale Supérieure / PSL, France · Department of Computing, Imperial College London, United Kingdom