Scalable
Vectorized per-sample gradient computation that is 10x faster than microbatching
Built on PyTorch
Supports most types of PyTorch models and can be used with minimal modification to the original neural network.
Extensible
Open source, modular API for differential privacy research. Everyone is welcome to contribute.
pip install opacus
git clone https://github.com/pytorch/opacus.git
cd opacus
pip install -e .
model = Net()
optimizer = SGD(model.parameters(), lr=0.05)
privacy_engine = PrivacyEngine(
model,
sample_rate=0.01,
alphas=[1, 10, 100],
noise_multiplier=1.3,
max_grad_norm=1.0,
)
privacy_engine.attach(optimizer)
# Now it's business as usual