forked from 626_privacy/tensorflow_privacy
Migrate dependency of tree_aggregation_accountant_test on rdp_accountant to differential_privacy.
PiperOrigin-RevId: 453989532
This commit is contained in:
parent
6c0cc858e0
commit
125f82707a
2 changed files with 11 additions and 6 deletions
|
@ -121,5 +121,7 @@ py_test(
|
||||||
deps = [
|
deps = [
|
||||||
":rdp_accountant",
|
":rdp_accountant",
|
||||||
":tree_aggregation_accountant",
|
":tree_aggregation_accountant",
|
||||||
|
"@com_google_differential_py//python/dp_accounting:dp_event",
|
||||||
|
"@com_google_differential_py//python/dp_accounting/rdp:rdp_privacy_accountant",
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
|
|
@ -16,9 +16,11 @@
|
||||||
from absl.testing import parameterized
|
from absl.testing import parameterized
|
||||||
import tensorflow as tf
|
import tensorflow as tf
|
||||||
|
|
||||||
from tensorflow_privacy.privacy.analysis import rdp_accountant
|
|
||||||
from tensorflow_privacy.privacy.analysis import tree_aggregation_accountant
|
from tensorflow_privacy.privacy.analysis import tree_aggregation_accountant
|
||||||
|
|
||||||
|
from com_google_differential_py.python.dp_accounting import dp_event
|
||||||
|
from com_google_differential_py.python.dp_accounting.rdp import rdp_privacy_accountant
|
||||||
|
|
||||||
|
|
||||||
class TreeAggregationTest(tf.test.TestCase, parameterized.TestCase):
|
class TreeAggregationTest(tf.test.TestCase, parameterized.TestCase):
|
||||||
|
|
||||||
|
@ -31,8 +33,8 @@ class TreeAggregationTest(tf.test.TestCase, parameterized.TestCase):
|
||||||
steps_list, target_delta = 1600, 1e-6
|
steps_list, target_delta = 1600, 1e-6
|
||||||
rdp = tree_aggregation_accountant.compute_rdp_tree_restart(
|
rdp = tree_aggregation_accountant.compute_rdp_tree_restart(
|
||||||
noise_multiplier, steps_list, orders)
|
noise_multiplier, steps_list, orders)
|
||||||
new_eps = rdp_accountant.get_privacy_spent(
|
new_eps = rdp_privacy_accountant.compute_epsilon(orders, rdp,
|
||||||
orders, rdp, target_delta=target_delta)[0]
|
target_delta)[0]
|
||||||
self.assertLess(new_eps, eps)
|
self.assertLess(new_eps, eps)
|
||||||
|
|
||||||
@parameterized.named_parameters(
|
@parameterized.named_parameters(
|
||||||
|
@ -65,8 +67,7 @@ class TreeAggregationTest(tf.test.TestCase, parameterized.TestCase):
|
||||||
for noise_multiplier in [0.1 * x for x in range(1, 100, 5)]:
|
for noise_multiplier in [0.1 * x for x in range(1, 100, 5)]:
|
||||||
rdp = tree_aggregation_accountant.compute_rdp_tree_restart(
|
rdp = tree_aggregation_accountant.compute_rdp_tree_restart(
|
||||||
noise_multiplier, steps_list, orders)
|
noise_multiplier, steps_list, orders)
|
||||||
eps = rdp_accountant.get_privacy_spent(
|
eps = rdp_privacy_accountant.compute_epsilon(orders, rdp, target_delta)[0]
|
||||||
orders, rdp, target_delta=target_delta)[0]
|
|
||||||
self.assertLess(eps, prev_eps)
|
self.assertLess(eps, prev_eps)
|
||||||
prev_eps = eps
|
prev_eps = eps
|
||||||
|
|
||||||
|
@ -89,7 +90,9 @@ class TreeAggregationTest(tf.test.TestCase, parameterized.TestCase):
|
||||||
orders = [1 + x / 10. for x in range(1, 100)] + list(range(12, 64))
|
orders = [1 + x / 10. for x in range(1, 100)] + list(range(12, 64))
|
||||||
tree_rdp = tree_aggregation_accountant.compute_rdp_tree_restart(
|
tree_rdp = tree_aggregation_accountant.compute_rdp_tree_restart(
|
||||||
noise_multiplier, [1] * total_steps, orders)
|
noise_multiplier, [1] * total_steps, orders)
|
||||||
rdp = rdp_accountant.compute_rdp(1., noise_multiplier, total_steps, orders)
|
accountant = rdp_privacy_accountant.RdpAccountant(orders)
|
||||||
|
accountant.compose(dp_event.GaussianDpEvent(noise_multiplier), total_steps)
|
||||||
|
rdp = accountant._rdp # pylint: disable=protected-access
|
||||||
self.assertAllClose(tree_rdp, rdp, rtol=1e-12)
|
self.assertAllClose(tree_rdp, rdp, rtol=1e-12)
|
||||||
|
|
||||||
@parameterized.named_parameters(
|
@parameterized.named_parameters(
|
||||||
|
|
Loading…
Reference in a new issue