NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

Mathematical analysis of the gradients in deep learning

Steffen Dereich, Thang Do, Arnulf Jentzen, Frederic WeberarXiv 2025 · DOI

Abstract

Deep learning frameworks frequently utilize non-differentiable components, such as the Rectified Linear Unit (ReLU), necessitating a departure from classical calculus. This paper provides a rigorous mathematical foundation for the "generalized gradients" employed in training these networks. By utilizing approximation theory and non-smooth analysis, the authors demonstrate that the heuristic gradient calculations in libraries like PyTorch and TensorFlow correspond to unique limiting Fréchet subgradients. This work bridges the gap between engineering practice and mathematical theory, establishing existence and uniqueness for generalized gradients in deep feedforward architectures.

The Challenge of Non-Differentiability

A significant "dirty secret" in deep learning is that its most popular tools are technically incompatible with classical calculus. The Rectified Linear Unit (ReLU) function, defined as $max\{x, 0\}$, is not differentiable at zero. Because modern neural networks are complex compositions of these functions, the resulting cost functions are frequently non-differentiable.

Despite this theoretical hurdle, practitioners successfully employ Stochastic Gradient Descent (SGD) daily. Frameworks like PyTorch typically "pick" a value for the gradient at non-differentiable points (often the left derivative). While effective in practice, this approach has historically lacked a solid theoretical guarantee regarding whether these "generalized gradients" behave like true gradients, their uniqueness, or their ability to guide the model toward a minimum. This research aims to formalize these engineering heuristics within a rigorous mathematical framework.

Theoretical Framework and Methodology

The authors employ a combination of approximation theory and non-smooth analysis to investigate the properties of gradients in deep fully-connected feedforward Artificial Neural Networks (ANNs).

Figure 1: A standard deep fully-connected feedforward neural network architecture, the primary subject of the paper's mathematical analysis.

The primary methodology involves a three-step approximation procedure:

  1. Smoothing: The researchers consider a sequence of continuously differentiable (smooth) functions that converge toward the non-smooth activation function (e.g., ReLU).
  2. Convergence Analysis: They prove that as these smooth approximations approach the target activation function, the gradients of the resulting cost functions converge to a unique "generalized gradient" function.
  3. Subgradient Calculus: The framework of limiting Fréchet subgradients—a generalization of the gradient for non-smooth functions—is used to categorize these limits.

This analytical approach allows for a formal derivation of the gradients used in practice, moving beyond simple heuristic selection.

Key Insights and Mathematical Results

The study yields several significant findings that validate current deep learning practices:

  • Mathematical Justification: The paper confirms that the programmatic methods used by major libraries to calculate gradients via the chain rule on generalized derivatives are mathematically sound.
  • Uniqueness: A critical finding is the uniqueness of the generalized gradient function under the proposed approximation procedure. This implies that the resulting generalized gradient is independent of the specific smoothing method used to analyze the ReLU function.
  • Variational Analysis Connection: By proving these gradients are "limiting Fréchet subgradients," the authors connect deep learning optimization to established variational analysis, providing a foundation for future convergence proofs.
  • Consistency with Classical Calculus: The generalized gradient perfectly matches the standard classical gradient on any open set where the cost function is differentiable.

The core of the research is encapsulated in Theorem 1.1 (and the generalized Theorem 3.14), which establishes that for a wide class of ANNs and loss functions, there exists a unique generalized gradient function $\mathcal{G}$ that serves as the limit of gradients from smooth approximations.

Limitations and Future Directions

While this work provides a foundational theory, several areas remain for future exploration:

  • Architectural Scope: The current analysis is restricted to fully-connected feedforward networks. Modern architectures like Transformers, CNNs, and layers involving BatchNorm introduce additional non-differentiability issues not yet covered.
  • Convergence Proofs: While the paper defines the nature of the gradient, it does not provide a comprehensive proof of SGD convergence in all non-smooth scenarios, though it provides the necessary tools to pursue such proofs.
  • Activation Functions: The focus remains primarily on ReLU and its variants. Other non-smooth components, such as MaxPool or quantization functions, require further explicit analysis.

Summary updated

BibTeX
@misc{dereich2025mathematical,
  author = {Steffen Dereich and Thang Do and Arnulf Jentzen and Frederic Weber},
  title = {{Mathematical analysis of the gradients in deep learning}},
  year = {2025},
  eprint = {2501.15646},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2501.15646},
}
Figure