{"about":{"site":"https://codewithpapers.app","non_affiliation":"Code with Papers and Syntology are not affiliated with, endorsed by, or sponsored by Papers with Code, Meta, or the pwc-archive mirror.","licence":"CC BY-SA 4.0","licence_url":"https://creativecommons.org/licenses/by-sa/4.0/legalcode","attribution":"https://codewithpapers.app/attribution","modified":"archive material modified by Syntology; see the attribution page"},"url":"/paper/fast-differentiable-clipping-aware","title":"Fast Differentiable Clipping-Aware Normalization and Rescaling","arxiv_id":"2007.07677","date":"2020-07-15","proceeding":null,"authors":["Jonas Rauber","Matthias Bethge"],"abstract":"Rescaling a vector $\\vec{\\delta} \\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 $\\eta \\vec{\\delta}$ 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} + \\eta \\vec{\\delta}$ 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{\\delta}$. The optimal rescaling $\\eta$ 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.","url_abs":"https://arxiv.org/abs/2007.07677v1","url_pdf":"https://arxiv.org/pdf/2007.07677v1.pdf","source":{"archive":"pwc-archive (Hugging Face), CC BY-SA 4.0","snapshot":"2025-07-28","licence_url":"https://creativecommons.org/licenses/by-sa/4.0/legalcode","row_kind":"abstracts"},"code_links":[{"paper_slug":"fast-differentiable-clipping-aware","repo_url":"https://github.com/jonasrauber/clipping-aware-rescaling","is_official":1,"mentioned_in_paper":1,"mentioned_in_github":1,"framework":"pytorch","reach":null}],"tasks":[],"methods":[],"datasets_introduced":[],"methods_introduced":[],"results":[],"syntology":{"atlas_url":"https://app.syntology.ai/?focus=2007.07677","mcp":null,"developers":"https://syntology.ai/developers"},"arxiv_metadata":null,"syntology_extracted_results":null}