Based on Google’s TF Privacy: https://github.com/tensorflow/privacy/blob/master/tensorflow_privacy/privacy/analysis/rdp_accountant.py. Here, we update this code to Python 3, and optimize dependencies.
Functionality for computing Renyi Differential Privacy (RDP) of an additive Sampled Gaussian Mechanism (SGM).
Suppose that we have run an SGM applied to a function with L2-sensitivity of 1.
Its parameters are given as a list of tuples
[(q_1, sigma_1, steps_1), ..., (q_k, sigma_k, steps_k)],
and we wish to compute epsilon for a given target delta.
The example code would be:
>>> max_order = 32 >>> orders = range(2, max_order + 1) >>> rdp = np.zeros_like(orders, dtype=float) >>> for q, sigma, steps in parameters: >>> rdp += privacy_analysis.compute_rdp(q, sigma, steps, orders) >>> epsilon, opt_order = privacy_analysis.get_privacy_spent(orders, rdp, delta)
compute_rdp(q, noise_multiplier, steps, orders)¶
Computes Renyi Differential Privacy (RDP) guarantees of the Sampled Gaussian Mechanism (SGM) iterated
float) – Sampling rate of SGM.
float) – The ratio of the standard deviation of the additive Gaussian noise to the L2-sensitivity of the function to which it is added. Note that this is same as the standard deviation of the additive Gaussian noise when the L2-sensitivity of the function is 1.
int) – The number of iterations of the mechanism.
- Return type
The RDP guarantees at all orders; can be np.inf.
get_privacy_spent(orders, rdp, delta)¶
Computes epsilon given a list of Renyi Differential Privacy (RDP) values at multiple RDP orders and target
- Return type
Pair of epsilon and optimal order alpha.
ValueError – If the lengths of
rdpare not equal.