41
41
eps, _, opt_order = rdp_accountant.get_privacy_spent(rdp, target_delta=delta)
42
42
"""
43
43
44
+ from com_google_differential_py .python .dp_accounting
44
45
import numpy as np
45
46
46
- from com_google_differential_py .python .dp_accounting import dp_event
47
- from com_google_differential_py .python .dp_accounting import privacy_accountant
48
- from com_google_differential_py .python .dp_accounting .rdp import rdp_privacy_accountant
49
-
50
47
51
48
def _compute_rdp_from_event (orders , event , count ):
52
49
"""Computes RDP from a DpEvent using RdpAccountant.
@@ -61,15 +58,14 @@ def _compute_rdp_from_event(orders, event, count):
61
58
"""
62
59
orders_vec = np .atleast_1d (orders )
63
60
64
- if isinstance (event , dp_event .SampledWithoutReplacementDpEvent ):
65
- neighboring_relation = privacy_accountant .NeighboringRelation .REPLACE_ONE
66
- elif isinstance (event , dp_event .SingleEpochTreeAggregationDpEvent ):
67
- neighboring_relation = privacy_accountant .NeighboringRelation .REPLACE_SPECIAL
61
+ if isinstance (event , dp_accounting .SampledWithoutReplacementDpEvent ):
62
+ neighboring_relation = dp_accounting .NeighboringRelation .REPLACE_ONE
63
+ elif isinstance (event , dp_accounting .SingleEpochTreeAggregationDpEvent ):
64
+ neighboring_relation = dp_accounting .NeighboringRelation .REPLACE_SPECIAL
68
65
else :
69
- neighboring_relation = privacy_accountant .NeighboringRelation .ADD_OR_REMOVE_ONE
66
+ neighboring_relation = dp_accounting .NeighboringRelation .ADD_OR_REMOVE_ONE
70
67
71
- accountant = rdp_privacy_accountant .RdpAccountant (orders_vec ,
72
- neighboring_relation )
68
+ accountant = dp_accounting .RdpAccountant (orders_vec , neighboring_relation )
73
69
accountant .compose (event , count )
74
70
rdp = accountant ._rdp # pylint: disable=protected-access
75
71
@@ -96,8 +92,8 @@ def compute_rdp(q, noise_multiplier, steps, orders):
96
92
Returns:
97
93
The RDPs at all orders. Can be `np.inf`.
98
94
"""
99
- event = dp_event .PoissonSampledDpEvent (
100
- q , dp_event .GaussianDpEvent (noise_multiplier ))
95
+ event = dp_accounting .PoissonSampledDpEvent (
96
+ q , dp_accounting .GaussianDpEvent (noise_multiplier ))
101
97
102
98
return _compute_rdp_from_event (orders , event , steps )
103
99
@@ -129,8 +125,8 @@ def compute_rdp_sample_without_replacement(q, noise_multiplier, steps, orders):
129
125
Returns:
130
126
The RDPs at all orders, can be np.inf.
131
127
"""
132
- event = dp_event .SampledWithoutReplacementDpEvent (
133
- 1 , q , dp_event .GaussianDpEvent (noise_multiplier ))
128
+ event = dp_accounting .SampledWithoutReplacementDpEvent (
129
+ 1 , q , dp_accounting .GaussianDpEvent (noise_multiplier ))
134
130
135
131
return _compute_rdp_from_event (orders , event , steps )
136
132
@@ -195,7 +191,7 @@ def get_privacy_spent(orders, rdp, target_eps=None, target_delta=None):
195
191
raise ValueError (
196
192
"Exactly one out of eps and delta must be None. (None is)." )
197
193
198
- accountant = rdp_privacy_accountant .RdpAccountant (orders )
194
+ accountant = dp_accounting .RdpAccountant (orders )
199
195
accountant ._rdp = rdp # pylint: disable=protected-access
200
196
201
197
if target_eps is not None :
0 commit comments