# Privacy Analysis¶

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).

Example

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)[source]

Computes Renyi Differential Privacy (RDP) guarantees of the Sampled Gaussian Mechanism (SGM) iterated steps times.

Parameters
Return type
Returns

The RDP guarantees at all orders; can be np.inf.

opacus.privacy_analysis.get_privacy_spent(orders, rdp, delta)[source]

Computes epsilon given a list of Renyi Differential Privacy (RDP) values at multiple RDP orders and target delta.

Parameters
Return type
Returns

Pair of epsilon and optimal order alpha.

Raises

ValueError – If the lengths of orders and rdp are not equal.