fl4health.privacy.moments_accountant module¶
- class FixedSamplingWithoutReplacement(population_size, sample_size)[source]¶
Bases:
SamplingStrategy
- class MomentsAccountant(moment_orders=None)[source]¶
Bases:
object
- __init__(moment_orders=None)[source]¶
Moment orders are equivalent to lambda from Deep Learning with Differential Privacy (Abadi et. al. 2016). They form the set of moments to estimate the infimum of Theorem 2 part 2. The default values were taken from the tensorflow federated DP tutorial notebook:
In the paper above, they state that trying lambda <= 32 is usually sufficient.
Sampling type is the data point sampling strategy: i.e. examples from dataset for a batch with probability q Noise type specifies whether Gaussian or Laplacian noise is added to the updates
- get_delta(sampling_strategies, noise_multiplier, updates, epsilon)[source]¶
If the parameters are lists, then it is assumed that the training applied the parameters in a sequence of updates.
Ex.
sampling_strategies = [PoissonSampling(q_1), PoissonSampling(q_2)] noise_multiplier = [z_1, z_2] updates = [t_1, t_2]
implies that
q_1
,z_1
were applied fort_1
updates, followed byq_2
,z_2
fort_2
updates.- Parameters:
sampling_strategies (SamplingStrategy | Sequence[SamplingStrategy]) –
Are the type of sampling done for each datapoint or client in the DP procedure. This is either Poisson sampling with a sampling rate specified or Fixed ratio sampling with a fixed number of selections performed over a specified population size. For non-FL DP-SGD: This is the ratio of batch size to dataset size (
L/N
, from Deep Learning with Differential Privacy). For FL with client-side DP-SGD (no noise on server side, instance level privacy): This is the ratio of client sampling probability to client data point probabilityq*(b_k/n_k)
For FL with client privacy: This is the sampling of clients from the client population.NOTE: If a sequence of strategies is given, they must be all of the same kind (that is poisson or subset, but may have different parameters)
noise_multiplier (float | list[float]) – Ratio of the noise standard deviation to clipping bound (sigma in Deep Learning with Differential Privacy, z in some other implementations).
updates (int | list[int]) – This is the number of noise applications to the update weights. For non-FL DP-SGD: This is the number of updates run (
epochs*batches per epoch
) For FL w/ client-side DP-SGD (instance DP): This is the number of batches run per client (if selected every time),server_updates*epochs per server update*batches per epoch
For FL with client privacy: Number of server updatesepsilon (float) – This is the epsilon in (epsilon, delta)-Privacy, that we require.
- Returns:
delta for the provided epsilon
- Return type:
- get_epsilon(sampling_strategies, noise_multiplier, updates, delta)[source]¶
If the parameters are lists, then it is assumed that the training applied the parameters in a sequence of updates.
Ex.
sampling_strategies = [PoissonSampling(q_1), PoissonSampling(q_2)] noise_multiplier = [z_1, z_2] updates = [t_1, t_2]
implies that
q_1
,z_1
were applied fort_1
updates, followed byq_2
,z_2
fort_2
updates.- Parameters:
sampling_strategies (SamplingStrategy | Sequence[SamplingStrategy]) –
Are the type of sampling done for each datapoint or client in the DP procedure. This is either Poisson sampling with a sampling rate specified or Fixed ratio sampling with a fixed number of selections performed over a specified population size. For non-FL DP-SGD: This is the ratio of batch size to dataset size (
L/N
, from Deep Learning with Differential Privacy). For FL with client-side DP-SGD (no noise on server side, instance level privacy): This is the ratio of client sampling probability to client data point probabilityq*(b_k/n_k)
For FL with client privacy: This is the sampling of clients from the client populationNOTE: If a sequence of strategies is given, they must be all of the same kind (that is poisson or subset, but may have different parameters)
noise_multiplier (float | list[float]) – Ratio of the noise standard deviation to clipping bound (sigma in Deep Learning with Differential Privacy,
z
in some other implementations).updates (int | list[int]) – This is the number of noise applications to the update weights. For non-FL DP-SGD: This is the number of updates run (
epochs*batches
per epoch) For FL w/ client-side DP-SGD (instance DP): This is the number of batches run per client (if selected every time),server_updates*epochs per server update*batches per epoch
. For FL with client privacy: Number of server updates.delta (float) – This is the delta in (epsilon, delta)-Privacy, that we require.
- Returns:
The corresponding epsilon
- Return type:
- class PoissonSampling(sampling_ratio)[source]¶
Bases:
SamplingStrategy