Yangfan-Jiang / Federated-Learning-with-Differential-Privacy

Implementation of dp-based federated learning framework using PyTorch
MIT License
274 stars 53 forks source link

how to computer the sensitivity #1

Closed KiteFlyKid closed 3 years ago

KiteFlyKid commented 3 years ago

Nice job! Where can I reference the way that you compute the sensitivity sensitivity = 2 * self.lr * self.clip / self.data_size + (self.E - 1) * 2 * self.lr * self.clip

By the way, are there any other implementations of dp algo except the Gaussian?

Yangfan-Jiang commented 3 years ago

The l2-sensitivity compution formula comes from one of our unpublished manuscripts. We encourage you to modify this part of the code according to your own needs (e.g., derive and compute l1-sensitivity for Laplace noise).

We haven't implemented Laplace or any other DP mechanism yet. You can add some functions to DPMechanisms.py to implement other mechanisms :-)

KiteFlyKid commented 3 years ago

Thanks for your reply For the 2rd question, I mean , you've already included so many functions in DPMechanisms.py but only the gaussian_noise_ls is used. So I am wondering what are the use of others or how can I use them?
Actually, I want to compare the effect of different DP algoes in my experiment where I propose a new FL framework and wanna incorporate a privacy preserving mechanism. But I am a newbie to DP so I hope that I can learn some stuff from others' code

Yangfan-Jiang commented 3 years ago

Some functions in DPMechanisms.py are not used for DP-FedAVG. For this repository, we aim to provide a basic framework for federated learning (Fed-AVG). Maybe you can find the implementation of other DP mechanisms from other repositories.

If you want to compare different DP alg, I suggest you derive and compute the l1/l2-sensitivity very carefully.
Please do not use sensitivity = 2 * self.lr * self.clip / self.data_size + (self.E - 1) * 2 * self.lr * self.clip directly on your new FL framework. Maybe you can find how to apply different DP mechanisms to FL from some published papers.

KiteFlyKid commented 3 years ago

many thanks for your suggestions