Skip to main content
QUICK REVIEW

[Paper Review] Fast Differentiable Clipping-Aware Normalization and Rescaling

Jonas Rauber, Matthias Bethge|arXiv (Cornell University)|Jul 15, 2020
Model Reduction and Neural NetworksPhysics and Astronomy5 references5 citations
TL;DR

This paper proposes a differentiable, non-iterative algorithm to compute the optimal rescaling of a perturbation vector such that its effective norm after clipping to a bounded data domain (e.g., [0,1]^n) matches a desired p-norm. By analytically solving the piecewise linear relationship between rescaling and clipping effects, the method enables exact, fast, and backpropagation-friendly normalization in applications like adversarial robustness and data augmentation.

ABSTRACT

Rescaling a vector $\vecδ \in \mathbb{R}^n$ to a desired length is a common operation in many areas such as data science and machine learning. When the rescaled perturbation $η\vecδ$ is added to a starting point $\vec{x} \in D$ (where $D$ is the data domain, e.g. $D = [0, 1]^n$), the resulting vector $\vec{v} = \vec{x} + η\vecδ$ will in general not be in $D$. To enforce that the perturbed vector $v$ is in $D$, the values of $\vec{v}$ can be clipped to $D$. This subsequent element-wise clipping to the data domain does however reduce the effective perturbation size and thus interferes with the rescaling of $\vecδ$. The optimal rescaling $η$ to obtain a perturbation with the desired norm after the clipping can be iteratively approximated using a binary search. However, such an iterative approach is slow and non-differentiable. Here we show that the optimal rescaling can be found analytically using a fast and differentiable algorithm. Our algorithm works for any p-norm and can be used to train neural networks on inputs with normalized perturbations. We provide native implementations for PyTorch, TensorFlow, JAX, and NumPy based on EagerPy.

Motivation & Objective

  • Address the problem that standard perturbation rescaling fails when clipped to bounded data domains like [0,1]^n, leading to reduced effective perturbation size.
  • Overcome the limitations of iterative binary search methods, which are slow and non-differentiable, for finding the correct rescaling factor after clipping.
  • Enable exact and differentiable control of perturbation size after clipping, crucial for training robust models and evaluating adversarial robustness.
  • Provide a general solution valid for any p-norm (1 ≤ p < ∞) and any bounded data domain [a,b]^n.
  • Support end-to-end differentiable training of neural networks using normalized perturbations, even when clipping is applied.

Proposed method

  • Formalize the problem as solving for η such that ||clip_a,b(x + ηδ) - x||_p = ε, where clipping reduces the effective perturbation size.
  • Express the p-th power of the effective perturbation norm as a piecewise linear function of η^p, derived from the clipping behavior at each dimension.
  • For each dimension i, define a critical threshold η_i = (c_i - x_i)/δ_i, where c_i is the clipping boundary (b if δ_i > 0, a if δ_i < 0), beyond which clipping occurs.
  • Group dimensions by their clipping threshold and sort them by η_i to enable efficient cumulative computation of the norm contribution.
  • Use a cumulative sum over sorted thresholds to compute the norm as a piecewise linear function of η^p, allowing analytical inversion to find the exact η.
  • Implement the algorithm efficiently using vectorized operations in NumPy, with native support for PyTorch, TensorFlow, JAX, and EagerPy for automatic differentiation.

Experimental results

Research questions

  • RQ1How can we analytically compute the rescaling factor η such that the effective perturbation norm after clipping matches a desired target ε?
  • RQ2Can we eliminate the need for iterative binary search in clipping-aware perturbation rescaling while preserving differentiability?
  • RQ3What is the mathematical structure of the norm of a clipped perturbation as a function of rescaling, and how can it be inverted efficiently?
  • RQ4How can this method be generalized across different p-norms and data domains without sacrificing computational efficiency?
  • RQ5To what extent can this approach improve the effectiveness and training efficiency of adversarial attacks and robustness training?

Key findings

  • The proposed algorithm computes the exact rescaling factor η analytically, avoiding iterative approximation and enabling full differentiability.
  • The method achieves non-iterative, exact normalization of perturbations after clipping, ensuring full utilization of the perturbation budget.
  • The algorithm is natively compatible with PyTorch, TensorFlow, JAX, and NumPy via EagerPy, enabling seamless integration into deep learning pipelines.
  • For p=2, the algorithm is implemented efficiently using sorted thresholds and cumulative sums, with computational complexity dominated by sorting.
  • The solution generalizes directly to any p-norm by replacing squaring and square roots with p-th power and root operations.
  • The method enables differentiable training of models with normalized perturbations, as demonstrated in adversarial noise attacks and learning of worst-case noise distributions.

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.