Skip to main content
Help the Python Software Foundation raise $60,000 USD by December 31st!  Building the PSF Q4 Fundraiser

Privacy preserving deep learning for PyTorch

Project description


PyVacy: Privacy Algorithms for PyTorch

PyVacy provides custom PyTorch opimizers for conducting deep learning in a differentially private manner. Basically TensorFlow Privacy, but for PyTorch.

Getting Started

pip install pyvacy

Example Usage

import torch
from pyvacy import optim, analysis

model = torch.nn.Sequential(...)

optimizer = optim.DPSGD(
    l2_norm_clip=...,
    noise_multiplier=...,
    batch_size=...,
    lr=...,
    momentum=...,
)

epsilon = analysis.moments_accountant(
    N=...,
    batch_size=...
    noise_multiplier=...,
    epochs=...,
    delta=...,
)

for epoch in range(epochs):
    # do training as usual...

Tutorials

python tutorials/mnist.py

Training procedure achieves (3.0, 0.00001)-DP
[Epoch 1/60] [Batch 0/235] [Loss: 2.321049]
[Epoch 1/60] [Batch 10/235] [Loss: 0.952795]
[Epoch 1/60] [Batch 20/235] [Loss: 1.040896]
...

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for pyvacy, version 0.0.32
Filename, size File type Python version Upload date Hashes
Filename, size pyvacy-0.0.32.tar.gz (10.3 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page