forked from 626_privacy/tensorflow_privacy
Remove TensorFlow Privacy dependency on six
.
Python 2 is not supported, please use Python 3. PiperOrigin-RevId: 424435761
This commit is contained in:
parent
1424cb2418
commit
47b439e376
6 changed files with 8 additions and 11 deletions
|
@ -42,9 +42,9 @@ from __future__ import print_function
|
||||||
|
|
||||||
import math
|
import math
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
from scipy import special
|
from scipy import special
|
||||||
import six
|
|
||||||
|
|
||||||
########################
|
########################
|
||||||
# LOG-SPACE ARITHMETIC #
|
# LOG-SPACE ARITHMETIC #
|
||||||
|
@ -106,7 +106,7 @@ def _log_comb(n, k):
|
||||||
|
|
||||||
def _compute_log_a_int(q, sigma, alpha):
|
def _compute_log_a_int(q, sigma, alpha):
|
||||||
"""Compute log(A_alpha) for integer alpha. 0 < q < 1."""
|
"""Compute log(A_alpha) for integer alpha. 0 < q < 1."""
|
||||||
assert isinstance(alpha, six.integer_types)
|
assert isinstance(alpha, int)
|
||||||
|
|
||||||
# Initialize with 0 in the log space.
|
# Initialize with 0 in the log space.
|
||||||
log_a = -np.inf
|
log_a = -np.inf
|
||||||
|
@ -486,7 +486,7 @@ def _compute_rdp_sample_without_replacement_int(q, sigma, alpha):
|
||||||
"""
|
"""
|
||||||
|
|
||||||
max_alpha = 256
|
max_alpha = 256
|
||||||
assert isinstance(alpha, six.integer_types)
|
assert isinstance(alpha, int)
|
||||||
|
|
||||||
if np.isinf(alpha):
|
if np.isinf(alpha):
|
||||||
return np.inf
|
return np.inf
|
||||||
|
|
|
@ -19,7 +19,7 @@ from typing import Collection, Optional
|
||||||
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
from scipy import special
|
from scipy import special
|
||||||
import six
|
|
||||||
from tensorflow_privacy.privacy.analysis import dp_event
|
from tensorflow_privacy.privacy.analysis import dp_event
|
||||||
from tensorflow_privacy.privacy.analysis import privacy_accountant
|
from tensorflow_privacy.privacy.analysis import privacy_accountant
|
||||||
|
|
||||||
|
@ -74,7 +74,7 @@ def _log_comb(n, k):
|
||||||
|
|
||||||
def _compute_log_a_int(q, sigma, alpha):
|
def _compute_log_a_int(q, sigma, alpha):
|
||||||
"""Computes log(A_alpha) for integer alpha, 0 < q < 1."""
|
"""Computes log(A_alpha) for integer alpha, 0 < q < 1."""
|
||||||
assert isinstance(alpha, six.integer_types)
|
assert isinstance(alpha, int)
|
||||||
|
|
||||||
# Initialize with 0 in the log space.
|
# Initialize with 0 in the log space.
|
||||||
log_a = -np.inf
|
log_a = -np.inf
|
||||||
|
@ -430,7 +430,7 @@ def _compute_rdp_sample_wor_gaussian_int(q, sigma, alpha):
|
||||||
"""
|
"""
|
||||||
|
|
||||||
max_alpha = 256
|
max_alpha = 256
|
||||||
assert isinstance(alpha, six.integer_types)
|
assert isinstance(alpha, int)
|
||||||
|
|
||||||
if np.isinf(alpha):
|
if np.isinf(alpha):
|
||||||
return np.inf
|
return np.inf
|
||||||
|
|
|
@ -19,7 +19,6 @@ from __future__ import print_function
|
||||||
|
|
||||||
from absl.testing import parameterized
|
from absl.testing import parameterized
|
||||||
import numpy as np
|
import numpy as np
|
||||||
from six.moves import xrange
|
|
||||||
import tensorflow.compat.v1 as tf
|
import tensorflow.compat.v1 as tf
|
||||||
|
|
||||||
from tensorflow_privacy.privacy.dp_query import gaussian_query
|
from tensorflow_privacy.privacy.dp_query import gaussian_query
|
||||||
|
@ -81,7 +80,7 @@ class GaussianQueryTest(tf.test.TestCase, parameterized.TestCase):
|
||||||
query_result, _ = test_utils.run_query(query, [record1, record2])
|
query_result, _ = test_utils.run_query(query, [record1, record2])
|
||||||
|
|
||||||
noised_sums = []
|
noised_sums = []
|
||||||
for _ in xrange(1000):
|
for _ in range(1000):
|
||||||
noised_sums.append(sess.run(query_result))
|
noised_sums.append(sess.run(query_result))
|
||||||
|
|
||||||
result_stddev = np.std(noised_sums)
|
result_stddev = np.std(noised_sums)
|
||||||
|
|
|
@ -19,7 +19,6 @@ from __future__ import print_function
|
||||||
|
|
||||||
from absl.testing import parameterized
|
from absl.testing import parameterized
|
||||||
import numpy as np
|
import numpy as np
|
||||||
from six.moves import range
|
|
||||||
import tensorflow.compat.v1 as tf
|
import tensorflow.compat.v1 as tf
|
||||||
|
|
||||||
from tensorflow_privacy.privacy.dp_query import gaussian_query
|
from tensorflow_privacy.privacy.dp_query import gaussian_query
|
||||||
|
|
|
@ -18,10 +18,10 @@ from __future__ import division
|
||||||
from __future__ import print_function
|
from __future__ import print_function
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
|
||||||
from absl.testing import parameterized
|
from absl.testing import parameterized
|
||||||
import mock
|
import mock
|
||||||
import numpy as np
|
import numpy as np
|
||||||
from six.moves import range
|
|
||||||
import tensorflow.compat.v1 as tf
|
import tensorflow.compat.v1 as tf
|
||||||
|
|
||||||
from tensorflow_privacy.privacy.dp_query import gaussian_query
|
from tensorflow_privacy.privacy.dp_query import gaussian_query
|
||||||
|
|
|
@ -20,7 +20,6 @@ from __future__ import print_function
|
||||||
from absl.testing import parameterized
|
from absl.testing import parameterized
|
||||||
import mock
|
import mock
|
||||||
import numpy as np
|
import numpy as np
|
||||||
from six.moves import range
|
|
||||||
import tensorflow.compat.v1 as tf
|
import tensorflow.compat.v1 as tf
|
||||||
|
|
||||||
from tensorflow_privacy.privacy.optimizers import dp_optimizer_vectorized
|
from tensorflow_privacy.privacy.optimizers import dp_optimizer_vectorized
|
||||||
|
|
Loading…
Reference in a new issue