Source-linked AI summary

Lipschitz regularity of deep neural networks: analysis and efficient estimation

Kevin Scaman, Aladin Virmaux

arXiv:1805.10965v2stat.MLcs.LG

TL;DR

The paper addresses the difficulty of estimating neural-network Lipschitz constants, whose exact computation is NP-hard even for simple networks. It introduces AutoLip and SeqLip, then shows that SeqLip can substantially tighten AutoLip bounds while remaining limited by high-dimensional optimization and large residual bounds.

  • Problem

    Estimating neural-network Lipschitz constants is important for robustness, but exact computation is NP-hard even for two-layer networks.

  • Method

    The paper introduces AutoLip for generic automatically differentiable functions and SeqLip, with heuristics, for sequential neural networks.

  • Results

    SeqLip improves AutoLip’s upper bound by a factor of 5 on a 10-layer CNN and by 6 fold on AlexNet, though the AlexNet bound remains large.

  • Takeaways & Limitations

    The proposed methods provide more precise practical upper-bound estimates than standard layerwise bounds for the tested neural networks.

  • Takeaways & Limitations

    SeqLip’s optimization remains hard in high-dimensional activation-gate spaces, and realistic networks may have dependent eigenvectors or insufficient spectral separation.

Abstract

from arXiv · show

Deep neural networks are notorious for being sensitive to small well-chosen perturbations, and estimating the regularity of such architectures is of utmost importance for safe and robust practical applications. In this paper, we investigate one of the key characteristics to assess the regularity of such methods: the Lipschitz constant of deep learning architectures. First, we show that, even for two layer neural networks, the exact computation of this quantity is NP-hard and state-of-art methods may significantly overestimate it. Then, we both extend and improve previous estimation methods by providing AutoLip, the first generic algorithm for upper bounding the Lipschitz constant of any automatically differentiable function. We provide a power method algorithm working with automatic differentiation, allowing efficient computations even on large convolutions. Second, for sequential neural networks, we propose an improved algorithm named SeqLip that takes advantage of the linear computation graph to split the computation per pair of consecutive layers. Third we propose heuristics on SeqLip in order to tackle very large networks. Our experiments show that SeqLip can significantly improve on the existing upper bounds. Finally, we provide an implementation of AutoLip in the PyTorch environment that may be used to better estimate the robustness of a given neural network to small perturbations or regularize it using more precise Lipschitz estimations.

1 Introduction

The paper studies Lipschitz constants as a way to assess neural-network regularity and robustness, motivated by sensitivity to small perturbations and applications including adversarial defense and generative modeling.

  • Small, well-chosen input perturbations can mislead neural networks and substantially reduce classification accuracy.
  • The Lipschitz constant upper bounds output variation induced by an input perturbation for a given distance.
  • Lipschitz continuity has supported robust learning, generative modeling, and deep-learning generalization bounds.
  • Existing analyses include products of spectral norms and methods specialized to scatter networks, but the latter do not extend to general architectures.
  • The paper proves exact estimation is NP-hard, introduces generic AutoLip bounds, develops automatic-differentiation power methods, and analyzes sequential-network refinements.

2 Background and notations

This section establishes notation for norms, compositions, Jacobians, and Lipschitz continuity, including the differential characterization used for later estimation methods.

  • The paper denotes scalar products, L2 norms, coordinate-wise products, function composition, Jacobians, gradients, and rectangular diagonal matrices.
  • A function is Lipschitz continuous when a finite constant bounds output-distance changes by input-distance changes.
  • The smallest valid bound is the function’s Lipschitz constant, denoted L(f).
  • For locally Lipschitz functions, the Lipschitz constant can be characterized through the differential operator almost everywhere.
  • For real-valued functions, L(f) equals the supremum of the gradient’s L2 norm over the domain.

3 Exact Lipschitz computation is NP-hard

Exact Lipschitz computation is NP-hard even for two-layer ReLU MLPs, motivating approximation algorithms that provide useful upper bounds.

  • The section focuses on MLPs, a basic neural-network architecture consisting of affine transformations and nonlinear activation functions.
  • Because exact computation is intractable under P ≠ NP, upper bounds are valuable for controlling output variation under input perturbations.
  • LIP-CST asks whether the Lipschitz constant of f = M2 ◦ ρ ◦ M1 with ReLU activation is at most ℓ.
  • Exact computation of a neural network’s Lipschitz constant is NP-hard even for two-layer MLPs.
  • The hardness result relies on reducing quadratic concave minimization on a hypercube to the Lipschitz decision problem using selected matrices M1 and M2.

4 AutoLip: a Lipschitz upper bound through automatic differentiation

AutoLip extends Lipschitz upper-bound estimation from standard MLPs to any automatically differentiable computation graph by propagating derivative bounds through its operations.

  • Automatic differentiation computes gradients and differential operators for functions formed from successive operations.
  • AutoLip represents a function as K successive operations in a computation graph and outputs an upper bound ˆLAL ≥ L(f).
  • The algorithm assumes locally Lipschitz operations whose partial derivatives can be computed and efficiently maximized.
  • AutoLip extends the product of operator norms for MLPs to any function computable in K operations.
  • Its feasible-value set fixes intermediate nodes independent of the input, removing unreachable graph branches from maximization.
  • For the illustrated function, AutoLip gives ˆLAL = 1 + ω, matching the exact Lipschitz constant.

5 Lipschitz constants of typical neural network layers

This section gives efficiently computable Lipschitz bounds for common neural-network layers and extends power-method estimation to automatically differentiable affine functions, including convolutions.

  • Linear and convolution layers: The Lipschitz constant of an affine function is the largest singular value of its matrix, computable to a chosen precision with the power method.The bias does not affect the associated matrix or the Lipschitz constant.
  • Linear and convolution layers: For large or inaccessible convolution matrices, automatic differentiation computes the matrix product required by the power method without explicitly materializing the matrix.The extension applies to any affine function compatible with automatic differentiation.
  • AutoGrad compliant power method: AutoGrad compliant power iteration approximates an affine function’s Lipschitz constant by repeatedly differentiating a squared output-difference norm.The algorithm normalizes each iterate and returns the output difference norm at the final iterate.
  • AutoGrad compliant power method: The power-method procedure is compatible with dynamic-graph libraries such as PyTorch and can also compute multiple leading singular values by iteration.Gradients can be obtained through autograd, while singular-value gradients also admit a closed-form expression.
  • Other layers: Most listed activation functions and max-pooling have Lipschitz constant 1, while dropout, batch normalization, and other pooling layers have explicit constants.The section treats these layerwise constants as building blocks for network-level estimation.

6 Sequential neural networks

SeqLip refines AutoLip for sequential networks by separating consecutive-layer effects and exploiting activation-gate structure. Its analysis links improvements to singular-vector misalignment, while heuristics address large search spaces and networks.

  • Motivation: AutoLip can accumulate multiplicative errors across computation steps, motivating a more refined analysis for multilayer perceptrons.For MLPs, the exact Lipschitz expression follows from the chain rule and intermediate layer outputs.
  • Theoretical analysis of SeqLip: When consecutive layers’ leading singular vectors misalign, diagonal activation operators cannot fully preserve the leading direction, reducing the Lipschitz constant below AutoLip’s multiplicative alignment scenario.The paper identifies this misalignment as the intuition behind SeqLip.
  • SeqLip, an improved algorithm for MLPs: Activation derivatives lie in [0, 1] for most major activations, allowing input-dependent gates to be replaced by a supremum over feasible gate values.This produces an upper-bound optimization over diagonal activation gates.
  • SeqLip, an improved algorithm for MLPs: SeqLip improves the bound by decomposing the network through singular-value decompositions and solving each activation layer independently.The decomposition uses submultiplicativity of the operator norm to split the computation into consecutive-layer components.
  • Heuristics: For small ReLU layers, SeqLip can search binary activation gates exhaustively; Greedy SeqLip instead uses gradient ascent and incurred at most 1% error when exact optima were computable.For very large layers, the heuristic retains a low-rank approximation with E = 200 eigenvectors in the reported experiments.
  • Theoretical analysis of SeqLip: With negligible second-to-first singular-value ratios, each activation layer can reduce the bound by roughly 1/π; for K = 5 layers, π^(K−1) ≈ 100.The result is strongest under small-ratio and vector-independence assumptions, which are acknowledged as less realistic.
  • Theoretical analysis of SeqLip: The idealized K = 5 estimate suggests a large SeqLip improvement, but the paper notes that real-layer eigenvectors are not independent and singular-value ratios may not be sufficiently small.Experiments indicate that eigenvector misalignment accounts for at least part of AutoLip’s suboptimality.

7 Experimentations

Experiments compare Lipschitz-constant estimation methods across idealized and trained MLPs, MNIST CNNs, and AlexNet. SeqLip generally narrows upper-bound gaps and substantially improves on AutoLip in deeper architectures.

  • Experimental setup: SeqLip is evaluated against grid search, simulated annealing, Frobenius-norm products, and spectral-norm products, with the first two providing lower bounds and the latter two upper bounds.For ReLU MLPs, first-order optimization is unusable because the objective is piecewise constant.
  • Ideal scenario: In the ideal MLP setting, SeqLip decreases as depth increases, while AutoLip remains fixed at 1 because every layer has spectral radius 1.The theoretical limit is tight when the eigenvalue ratio is small.
  • MLP: Greedy SeqLip stays within 0.01% of SeqLip on the synthetic MLP experiments, supporting its use in higher dimensions.The networks use 20 neurons per layer, ReLU activations, and a 2-dimensional Gaussian-process dataset.
  • MLP: SeqLip outperforms competing upper bounds on the trained MLPs, reducing the gap to the grid-search estimate of the true Lipschitz constant.Grid search performs well in d = 2, whereas simulated annealing is suboptimal, probably because of local maxima.
  • CNN: SeqLip improves the AutoLip upper bound by a factor of 5 for the 10-layer MNIST CNN.The simulated-annealing lower bounds are probably too low based on the preceding experiments.
  • AlexNet: For AlexNet, AutoLip gives 3.62 × 10^7, while Greedy SeqLip gives 5.45 × 10^6, a 6-fold improvement that remains extremely large.The authors note that these results use different weights from the cited prior work.

8 Conclusion

The paper establishes computational hardness for exact Lipschitz constants, then develops AutoLip and SeqLip to obtain practical upper bounds. SeqLip can improve AutoLip substantially, although bounds remain very large for some computer-vision networks.

  • Exact computation of a neural network’s Lipschitz constant is NP-hard, even for two-layer networks.
  • AutoLip provides a generic upper bound for any automatically differentiable function and efficiently computes singular values of affine operators such as convolutions through autograd.
  • SeqLip refines AutoLip for MLPs by exploiting the linear computation graph and can improve its upper bound by up to a factor of 8.
  • AutoLip and SeqLip bounds remain extremely large for computer-vision networks such as AlexNet, and their closeness to the true constant remains open.

A Proof of Theorem 2

The proof reduces a known NP-hard quadratic optimization problem on a hypercube to exact Lipschitz computation for a two-layer ReLU MLP.

  • The reduction starts from maximizing a positive-semidefinite quadratic convex function over a hypercube, an NP-hard optimization problem.
  • The constructed two-layer MLP recovers the target quadratic optimization formulation, with no recursive loop in the computation.
  • Because the matrix H is full rank, the first linear layer is surjective and all activation-derivative vectors are admissible.
  • ReLU derivatives lie in {0, 1}, and the proof replaces this discrete condition with a relaxed optimization problem having the same optimum points.

B Proof of Theorem 3

The proof bounds the product of two consecutive linear operators by separating dominant singular directions from residual components. This yields a tighter estimate than multiplying their largest singular values alone.

  • The operator decomposition isolates the largest singular values and separates them from residual diagonal components.
  • Orthogonality of the singular-vector bases converts the residual contributions into norm and inner-product terms.
  • The resulting inequality combines leading-direction alignment with residual ratios er1 and er2.
  • AutoLip’s bound for the pair is s1s′1, whereas the refined inequality can account for directional misalignment before taking the maximum over activation derivatives.

C Proof of Lemma 2

The proof constructs independent Gaussian directions uniformly distributed on the unit sphere, uses symmetry and almost-sure convergence, and evaluates the limiting expectation to obtain the desired result.

  • Normalizing two independent n-dimensional Gaussian vectors produces independent random directions uniformly distributed on the unit sphere.
  • The positive and negative parts of each scalar are defined as x+ = max{0, x} and x− = max{0, −x}.
  • Symmetry of the direction distributions with respect to coordinate axes gives the same law for the relevant positive- and negative-part sums.
  • The relevant terms converge almost surely to their expectations by the strong law of large numbers.
  • 1/2 E[|U_i V_i|] = 1/π after factorizing the independent absolute moments, yielding the desired result.
Loading 1805.10965v2…