Coder Social home page Coder Social logo

edurle / opacus Goto Github PK

View Code? Open in Web Editor NEW

This project forked from pytorch/opacus

1.0 0.0 0.0 4.52 MB

Training PyTorch models with differential privacy

Home Page: https://opacus.ai

License: Apache License 2.0

Python 29.06% Jupyter Notebook 65.81% JavaScript 1.75% Shell 0.49% Makefile 0.05% Batchfile 0.06% CSS 2.78%

opacus's Introduction

Opacus


CircleCI

Opacus is a library that enables training PyTorch models with differential privacy. It supports training with minimal code changes required on the client, has little impact on training performance, and allows the client to online track the privacy budget expended at any given moment.

Target audience

This code release is aimed at two target audiences:

  1. ML practitioners will find this to be a gentle introduction to training a model with differential privacy as it requires minimal code changes.
  2. Differential Privacy researchers will find this easy to experiment and tinker with, allowing them to focus on what matters.

Installation

The latest release of Opacus can be installed via pip:

pip install opacus

You can also install directly from the source for the latest features (along with its quirks and potentially ocassional bugs):

git clone https://github.com/pytorch/opacus.git
cd opacus
pip install -e .

Getting started

To train your model with differential privacy, all you need to do is to instantiate a PrivacyEngine and pass your model, data_loader, and optimizer to the engine's make_private() method to obtain their private counterparts.

# define your components as usual
model = Net()
optimizer = SGD(model.parameters(), lr=0.05)
data_loader = torch.utils.data.DataLoader(dataset, batch_size=1024)

# enter PrivacyEngine
privacy_engine = PrivacyEngine()
model, optimizer, data_loader = privacy_engine.make_private(
    module=model,
    optimizer=optimizer,
    data_loader=data_loader,
    noise_multiplier=1.1,
    max_grad_norm=1.0,
)
# Now it's business as usual

The MNIST example shows an end-to-end run using opacus. The examples folder contains more such examples.

Migrating to 1.0

Opacus 1.0 introduced many improvements to the library, but also some breaking changes. If you've been using Opacus 0.x and want to update to the latest release, please use this Migration Guide

Learn more

Interactive tutorials

We've built a series of IPython-based tutorials as a gentle introduction to training models with privacy and using various Opacus features.

Blogposts and talks

If you want to learn more about DP-SGD and related topics, check our our series of blogposts and talks:

FAQ

Checkout the FAQ page for answers to some of the most frequently asked questions about Differential Privacy and Opacus.

Contributing

See the CONTRIBUTING file for how to help out. Do also check out the README files inside the repo to learn how the code is organized.

Citation

To cite Opacus in your papers (much appreciated!), please use the following:

@article{opacus,
  title={Opacus: User-Friendly Differential Privacy Library in PyTorch},
  author={A. Yousefpour and I. Shilov and A. Sablayrolles and D. Testuggine and K. Prasad and M. Malek and J. Nguyen and S. Ghosh and A. Bharadwaj and J. Zhao and G. Cormode and I. Mironov},
  journal={arXiv preprint arXiv:2109.12298},
  year={2021}
}

License

This code is released under Apache 2.0, as found in the LICENSE file.

opacus's People

Contributors

karthikprasad avatar darktex avatar ashkan-software avatar anonymani avatar sayanghosh avatar dependabot[bot] avatar akashb-fb avatar touqir14 avatar facebook-github-bot avatar ftramer avatar stanislavglebik avatar lariffle avatar jessijzhao avatar carlodavid012 avatar constancebeguier avatar ezyang avatar ilyamironov avatar jmg-74 avatar madhavajay avatar mmalekzadeh avatar romovpa avatar pierrestock avatar tholop avatar walterddr avatar royrin avatar yangshun avatar zejunh avatar gszh avatar

Stargazers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.