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)
- opacus.privacy_analysis.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
- opacus.privacy_analysis.get_privacy_spent(orders, rdp, delta)¶
Computes epsilon given a list of Renyi Differential Privacy (RDP) values at multiple RDP orders and target
delta. The computation of epslion, i.e. conversion from RDP to (eps, delta)-DP, is based on the theorem presented in the following work: Borja Balle et al. “Hypothesis testing interpretations and Renyi differential privacy.” International Conference on Artificial Intelligence and Statistics. PMLR, 2020. Particullary, Theorem 21 in the arXiv version https://arxiv.org/abs/1905.09982. :type orders:
float] :param orders: An array (or a scalar) of orders (alphas). :type rdp:
float] :param rdp: A list (or a scalar) of RDP guarantees. :type delta:
float:param delta: The target delta.