Skip to main content
QUICK REVIEW

[Paper Review] On Correctness of Automatic Differentiation for Non-Differentiable Functions

Wonyeol Lee, Hangyeol Yu|arXiv (Cornell University)|Jun 11, 2020
Neural Networks and ApplicationsComputer Science10 citations
TL;DR

This paper establishes the formal correctness of automatic differentiation (autodiff) systems when applied to non-differentiable functions—common in deep learning—by introducing intensional derivatives for a broad class of functions called PAP (piecewise analyticity under analytic partition). It proves these derivatives always exist and match standard derivatives almost everywhere, showing that autodiff systems effectively compute them, thus justifying their widespread use despite theoretical concerns about non-differentiabilities.

ABSTRACT

Differentiation lies at the core of many machine-learning algorithms, and is well-supported by popular autodiff systems, such as TensorFlow and PyTorch. Originally, these systems have been developed to compute derivatives of differentiable functions, but in practice, they are commonly applied to functions with non-differentiabilities. For instance, neural networks using ReLU define non-differentiable functions in general, but the gradients of losses involving those functions are computed using autodiff systems in practice. This status quo raises a natural question: are autodiff systems correct in any formal sense when they are applied to such non-differentiable functions? In this paper, we provide a positive answer to this question. Using counterexamples, we first point out flaws in often-used informal arguments, such as: non-differentiabilities arising in deep learning do not cause any issues because they form a measure-zero set. We then investigate a class of functions, called PAP functions, that includes nearly all (possibly non-differentiable) functions in deep learning nowadays. For these PAP functions, we propose a new type of derivatives, called intensional derivatives, and prove that these derivatives always exist and coincide with standard derivatives for almost all inputs. We also show that these intensional derivatives are what most autodiff systems compute or try to compute essentially. In this way, we formally establish the correctness of autodiff systems applied to non-differentiable functions.

Motivation & Objective

  • To address the theoretical concern of whether autodiff systems are correct when applied to non-differentiable functions, especially in deep learning.
  • To challenge and correct flawed informal justifications—such as non-differentiabilities being measure-zero—commonly used to defend autodiff in practice.
  • To define a formal correctness condition for autodiff systems that permits non-differentiable functions as long as non-differentiability occurs on a measure-zero set.
  • To introduce and analyze a new class of functions (PAP functions) that capture nearly all modern deep learning functions, including ReLU-based networks.
  • To define intensional derivatives for PAP functions and prove they exist almost everywhere and satisfy key properties like the chain rule.

Proposed method

  • Introduce the class of PAP functions, which are functions that are piecewise analytic with analytic partitioning, and include most deep learning functions.
  • Define intensional derivatives as a new type of derivative that generalizes standard derivatives to non-differentiable points.
  • Prove that intensional derivatives exist for all PAP functions and coincide with standard derivatives almost everywhere (a.e.).
  • Show that intensional derivatives satisfy a generalized chain rule even for non-differentiable functions.
  • Demonstrate that most existing autodiff systems compute or approximate intensional derivatives, thus justifying their practical correctness.
  • Use measure-theoretic arguments and properties of analytic functions to establish existence and consistency of intensional derivatives.

Experimental results

Research questions

  • RQ1Are autodiff systems formally correct when applied to non-differentiable functions, such as those with ReLU activations?
  • RQ2Do common heuristic arguments—e.g., non-differentiabilities form a measure-zero set—suffice to justify autodiff correctness?
  • RQ3Can a new derivative concept be defined for non-differentiable functions that ensures correctness and consistency with standard derivatives almost everywhere?
  • RQ4Do intensional derivatives satisfy fundamental calculus rules like the chain rule even when functions are non-differentiable?
  • RQ5To what extent do existing autodiff systems compute or approximate these intensional derivatives?

Key findings

  • Intensional derivatives exist for all PAP functions and coincide with standard derivatives almost everywhere.
  • The chain rule holds for intensional derivatives even when functions are non-differentiable, ensuring consistency in composition.
  • Most existing autodiff systems effectively compute or approximate intensional derivatives, justifying their practical correctness.
  • The class of PAP functions includes nearly all functions used in modern deep learning, such as those with ReLU and other piecewise analytic activations.
  • Counterexamples show that the common heuristic—non-differentiabilities are rare and thus harmless—is insufficient and flawed.
  • The paper establishes a formal correctness condition for autodiff systems that allows non-differentiable functions as long as non-differentiability occurs on a measure-zero set.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.