jax_privacy.accounting

Functions for creating DpEvent objects for common JAX Privacy mechanisms.

Example Usage (Calculating Epsilon for DP-SGD):

>>> import dp_accounting
>>> event = dpsgd_event(noise_multiplier=3, iterations=512, sampling_prob=0.1)
>>> accountant = dp_accounting.pld.PLDAccountant()
>>> epsilon = accountant.compose(event).get_epsilon(target_delta=1e-6)
>>> round(epsilon, 2)
3.77

Example Usage (Calibrating Noise Multiplier for DP-SGD):

>>> make_event = lambda sigma: dpsgd_event(sigma, 512, sampling_prob=0.1)
>>> noise_multiplier = dp_accounting.calibrate_dp_mechanism(
...     dp_accounting.pld.PLDAccountant,
...     make_event,
...     target_epsilon=1.0,
...     target_delta=1e-6
... )
>>> round(noise_multiplier, 2)
9.66

Example Usage (Calibrating Number of Iterations for DP-SGD):

>>> make_event = lambda t: dpsgd_event(3.0, t, sampling_prob=0.1)
>>> dp_accounting.calibrate_dp_mechanism(
...     dp_accounting.pld.PLDAccountant,
...     make_event,
...     target_epsilon=2.0,
...     target_delta=1e-6,
...     discrete=True,
...     bracket_interval=dp_accounting.LowerEndpointAndGuess(1, 128)
... )
155

Functions

amplified_bandmf_event(noise_multiplier, ...)

Returns the DpEvent for DP-BandMF with the given training parameters.

dpsgd_event(noise_multiplier, iterations, *, ...)

Returns the DpEvent for DP-SGD with the given training parameters.

fixed_dpsgd_event(noise_multiplier, ...[, ...])

Returns the DpEvent for DP-SGD with fixed-size sampling.

truncated_amplified_bandmf_event(...)

Returns the DpEvent for truncated DP-BandMF with the given parameters.

truncated_dpsgd_event(noise_multiplier, ...)

Returns the DpEvent for truncated DP-SGD with the given training params.