Package: deel-torchlip
deel-torchlipis an open source Python API to
build and train Lipschitz neural networks. It is built on top of PyTorch.deel-torchlip provides:Easy-to-use Lipschitz layers-- deel-torchlip layers are custom PyTorch layers and
are very user-friendly. No need to be an expert in Lipschitz networks!Custom losses for robustness-- The provided losses help improving adversarial
robustness in classification tasks by increasing margins between outputs of the
network (seeour paperfor more information).Certified robustness-- One main advantage of Lipschitz networks is the costless
computation of certificates ensuring that there is no adversarial attacks smaller than
these certified radii of robustness.For TensorFlow/Keras users, we released thedeel-lippackage offering a similar
implementation based on Keras.InstallThe latest release can be installed usingpip. Thetorchpackage will also be
installed as a dependency. Iftorchis already present, be sure that the version is
compatible with the deel-torchlip version.$pipinstalldeel-torchlipUsageCreating a Lipschitz network is similar to building a PyTorch model: standard layers are
replaced with their Lipschitz counterparts from deel-torchlip. PyTorch layers that are
already Lipschitz can still be used in Lipschitz networks, such astorch.nn.ReLU()ortorch.nn.Flatten().importtorchfromdeelimporttorchlip# Build a Lipschitz network with 4 layers, that can be used in a training loop,# like any torch.nn.Sequential networkmodel=torchlip.Sequential(torchlip.SpectralConv2d(in_channels=3,out_channels=16,kernel_size=(3,3),padding="same"),torchlip.GroupSort2(),torch.nn.Flatten(),torchlip.SpectralLinear(15544,64))See thefull documentationfor a complete API
description and for our tutorials to get started.CitationThis library was built to support the work presented in our CVPR 2021 paperAchieving robustness in classification using optimal transport with Hinge regularization.
If you use our library for your work, please cite our paper :wink:@misc{2006.06520,
Author ={Mathieu Serrurier and Franck Mamalet and Alberto González-Sanz and Thibaut Boissin and Jean-Michel Loubes and Eustasio del Barrio},
Title ={Achieving robustness in classification using optimal transport with hinge regularization},
Year ={2020},
Eprint ={arXiv:2006.06520},}ContributionsContributions are welcome! You can open anissueor fork this repository and
propose apull-request. The
development environment with all required dependencies should be installed by running:$makeprepare-devCode formatting and linting are performed withblackandflake8. Tests are run withpytest. These three commands are gathered in:$maketestFinally, commits should respect pre-commit hooks. To be sure that your code changes are
accepted, you can run the following target:$makecheck_allLicenseCopyright IRT Antoine de Saint Exupéry et Université Paul Sabatier Toulouse III - All
rights reserved. DEEL is a research program operated by IVADO, IRT Saint Exupéry, CRIAQ
and ANITI -https://www.deel.ai/Permission is hereby granted, free of charge, to any person obtaining a copy of this
software and associated documentation files (the "Software"), to deal in the Software
without restriction, including without limitation the rights to use, copy, modify,
merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to the following
conditions:The above copyright notice and this permission notice shall be included in all copies or
substantial portions of the Software.THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT
OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.AcknowledgmentsThis project received funding from the French "Investing for the Future – PIA3" program
within the Artiﬁcial and Natural Intelligence Toulouse Institute (ANITI). The authors
gratefully acknowledge the support of theDEEL project.