FedML-AI/FedML

DP Sensitivity Calculation

eardic opened this issue · 1 comments

eardic commented

Hi,

I don't understand how to set the sensitivity of DP to determine the noise level for the model weights. For example for a local dp process, can you recommend a way to compute sensitivity for this code block? In literature, it is said that sensitivity is computed by measuring the change in the output of the model by removing or changing an input.

class Laplace:

def __init__(self, *, epsilon, delta=0.0, sensitivity):
    self.scale = float(sensitivity) / (float(epsilon) - np.log(1 - float(delta)))

def compute_noise(self, size):
    return torch.tensor(np.random.laplace(loc=0.0, scale=self.scale, size=size))

Hi, it depends on the application and the privacy-accuracy trade-off. We will also release a new api that allows to define the laplace mechanism using the scale parameter soon.