From 125f82707abc7201760326ce7492a9c5f2a41828 Mon Sep 17 00:00:00 2001 From: Galen Andrew Date: Thu, 9 Jun 2022 12:43:40 -0700 Subject: [PATCH] Migrate dependency of tree_aggregation_accountant_test on rdp_accountant to differential_privacy. PiperOrigin-RevId: 453989532 --- tensorflow_privacy/privacy/analysis/BUILD | 2 ++ .../analysis/tree_aggregation_accountant_test.py | 15 +++++++++------ 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/tensorflow_privacy/privacy/analysis/BUILD b/tensorflow_privacy/privacy/analysis/BUILD index 68a7fe2..940baee 100644 --- a/tensorflow_privacy/privacy/analysis/BUILD +++ b/tensorflow_privacy/privacy/analysis/BUILD @@ -121,5 +121,7 @@ py_test( deps = [ ":rdp_accountant", ":tree_aggregation_accountant", + "@com_google_differential_py//python/dp_accounting:dp_event", + "@com_google_differential_py//python/dp_accounting/rdp:rdp_privacy_accountant", ], ) diff --git a/tensorflow_privacy/privacy/analysis/tree_aggregation_accountant_test.py b/tensorflow_privacy/privacy/analysis/tree_aggregation_accountant_test.py index 3cb2926..e94551c 100644 --- a/tensorflow_privacy/privacy/analysis/tree_aggregation_accountant_test.py +++ b/tensorflow_privacy/privacy/analysis/tree_aggregation_accountant_test.py @@ -16,9 +16,11 @@ from absl.testing import parameterized import tensorflow as tf -from tensorflow_privacy.privacy.analysis import rdp_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): @@ -31,8 +33,8 @@ class TreeAggregationTest(tf.test.TestCase, parameterized.TestCase): steps_list, target_delta = 1600, 1e-6 rdp = tree_aggregation_accountant.compute_rdp_tree_restart( noise_multiplier, steps_list, orders) - new_eps = rdp_accountant.get_privacy_spent( - orders, rdp, target_delta=target_delta)[0] + new_eps = rdp_privacy_accountant.compute_epsilon(orders, rdp, + target_delta)[0] self.assertLess(new_eps, eps) @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)]: rdp = tree_aggregation_accountant.compute_rdp_tree_restart( noise_multiplier, steps_list, orders) - eps = rdp_accountant.get_privacy_spent( - orders, rdp, target_delta=target_delta)[0] + eps = rdp_privacy_accountant.compute_epsilon(orders, rdp, target_delta)[0] self.assertLess(eps, prev_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)) tree_rdp = tree_aggregation_accountant.compute_rdp_tree_restart( 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) @parameterized.named_parameters(