All Projects → pytorch → Opacus

pytorch / Opacus

Licence: apache-2.0
Training PyTorch models with differential privacy

Projects that are alternatives of or similar to Opacus

Causal inference python code
Python code for part 2 of the book Causal Inference: What If, by Miguel Hernán and James Robins
Stars: ✭ 748 (-1.97%)
Mutual labels:  jupyter-notebook
Jupyterhub
Multi-user server for Jupyter notebooks
Stars: ✭ 6,488 (+750.33%)
Mutual labels:  jupyter-notebook
Tffm
TensorFlow implementation of an arbitrary order Factorization Machine
Stars: ✭ 761 (-0.26%)
Mutual labels:  jupyter-notebook
Notes Machine Learning
鉴于我没有时间继续写这个东西,这个项目暂时废止
Stars: ✭ 750 (-1.7%)
Mutual labels:  jupyter-notebook
Graphneuralnetwork
《深入浅出图神经网络:GNN原理解析》配套代码
Stars: ✭ 754 (-1.18%)
Mutual labels:  jupyter-notebook
Entity Embedding Rossmann
Stars: ✭ 758 (-0.66%)
Mutual labels:  jupyter-notebook
Gans In Action
Companion repository to GANs in Action: Deep learning with Generative Adversarial Networks
Stars: ✭ 748 (-1.97%)
Mutual labels:  jupyter-notebook
Ktrain
ktrain is a Python library that makes deep learning and AI more accessible and easier to apply
Stars: ✭ 763 (+0%)
Mutual labels:  jupyter-notebook
Automatic Watermark Detection
Project for Digital Image Processing
Stars: ✭ 754 (-1.18%)
Mutual labels:  jupyter-notebook
Ec2 Spot Labs
Collection of tools and code examples to demonstrate best practices in using Amazon EC2 Spot Instances.
Stars: ✭ 758 (-0.66%)
Mutual labels:  jupyter-notebook
Learning From Data
记录Learning from data一书中的习题解答
Stars: ✭ 751 (-1.57%)
Mutual labels:  jupyter-notebook
Machine learning refined
Notes, examples, and Python demos for the textbook "Machine Learning Refined" (published by Cambridge University Press).
Stars: ✭ 750 (-1.7%)
Mutual labels:  jupyter-notebook
Notedown
Markdown <=> IPython Notebook
Stars: ✭ 757 (-0.79%)
Mutual labels:  jupyter-notebook
Finetune alexnet with tensorflow
Code for finetuning AlexNet in TensorFlow >= 1.2rc0
Stars: ✭ 748 (-1.97%)
Mutual labels:  jupyter-notebook
Jupyter2slides
Cloud Native Presentation Slides with Jupyter Notebook + Reveal.js
Stars: ✭ 762 (-0.13%)
Mutual labels:  jupyter-notebook
Deeprl Tutorials
Contains high quality implementations of Deep Reinforcement Learning algorithms written in PyTorch
Stars: ✭ 748 (-1.97%)
Mutual labels:  jupyter-notebook
Deep Learning Coursera
Deep Learning Specialization by Andrew Ng on Coursera.
Stars: ✭ 6,615 (+766.97%)
Mutual labels:  jupyter-notebook
996quant
35岁程序员退路之量化投资学习笔记
Stars: ✭ 766 (+0.39%)
Mutual labels:  jupyter-notebook
Superpoint
Efficient neural feature detector and descriptor
Stars: ✭ 761 (-0.26%)
Mutual labels:  jupyter-notebook
Ml Course Msu
Lecture notes and code for Machine Learning practical course on CMC MSU
Stars: ✭ 759 (-0.52%)
Mutual labels:  jupyter-notebook

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 scientists 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

⚠️ NOTE: This will bring in the latest version of our deps, which are on Cuda 10.2. This will not work if you environment is using an older Cuda version (for example, Google Colab is still on Cuda 10.1).

To install on Colab, run this cell first:

pip install torchcsprng==0.1.3+cu101 -f https://download.pytorch.org/whl/torch_stable.html

Then you can just pip install opacus like before. See more context in this issue.

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 declare a PrivacyEngine and attach it to your optimizer before running, eg:

model = Net()
optimizer = SGD(model.parameters(), lr=0.05)
privacy_engine = PrivacyEngine(
    model,
    sample_rate=0.01,
    alphas=[10, 100],
    noise_multiplier=1.3,
    max_grad_norm=1.0,
)
privacy_engine.attach(optimizer)
# Now it's business as usual

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

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.

References

License

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

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].