diff --git a/tensorflow_privacy/__init__.py b/tensorflow_privacy/__init__.py index 5db9cc3..9e8aa63 100644 --- a/tensorflow_privacy/__init__.py +++ b/tensorflow_privacy/__init__.py @@ -13,10 +13,6 @@ # limitations under the License. """TensorFlow Privacy library.""" -from __future__ import absolute_import -from __future__ import division -from __future__ import print_function - import sys from tensorflow_privacy.version import __version__ # pylint: disable=g-bad-import-order diff --git a/tensorflow_privacy/privacy/analysis/compute_dp_sgd_privacy.py b/tensorflow_privacy/privacy/analysis/compute_dp_sgd_privacy.py index e9d999d..84f5e2e 100644 --- a/tensorflow_privacy/privacy/analysis/compute_dp_sgd_privacy.py +++ b/tensorflow_privacy/privacy/analysis/compute_dp_sgd_privacy.py @@ -28,10 +28,6 @@ Example: The output states that DP-SGD with these parameters satisfies (2.92, 1e-5)-DP. """ -from __future__ import absolute_import -from __future__ import division -from __future__ import print_function - from absl import app from absl import flags diff --git a/tensorflow_privacy/privacy/analysis/compute_dp_sgd_privacy_lib.py b/tensorflow_privacy/privacy/analysis/compute_dp_sgd_privacy_lib.py index 8d081c5..7cc557a 100644 --- a/tensorflow_privacy/privacy/analysis/compute_dp_sgd_privacy_lib.py +++ b/tensorflow_privacy/privacy/analysis/compute_dp_sgd_privacy_lib.py @@ -14,10 +14,6 @@ # ============================================================================== """Library for computing privacy values for DP-SGD.""" -from __future__ import absolute_import -from __future__ import division -from __future__ import print_function - import math from absl import app diff --git a/tensorflow_privacy/privacy/analysis/compute_dp_sgd_privacy_test.py b/tensorflow_privacy/privacy/analysis/compute_dp_sgd_privacy_test.py index 267bd06..c1431db 100644 --- a/tensorflow_privacy/privacy/analysis/compute_dp_sgd_privacy_test.py +++ b/tensorflow_privacy/privacy/analysis/compute_dp_sgd_privacy_test.py @@ -13,10 +13,6 @@ # limitations under the License. # ============================================================================== -from __future__ import absolute_import -from __future__ import division -from __future__ import print_function - import math from absl.testing import absltest diff --git a/tensorflow_privacy/privacy/analysis/compute_noise_from_budget.py b/tensorflow_privacy/privacy/analysis/compute_noise_from_budget.py index 731c9ac..01e7368 100644 --- a/tensorflow_privacy/privacy/analysis/compute_noise_from_budget.py +++ b/tensorflow_privacy/privacy/analysis/compute_noise_from_budget.py @@ -30,10 +30,6 @@ The output states that DP-SGD with these parameters should use a noise multiplier of 1.12. """ -from __future__ import absolute_import -from __future__ import division -from __future__ import print_function - from absl import app from absl import flags diff --git a/tensorflow_privacy/privacy/analysis/compute_noise_from_budget_lib.py b/tensorflow_privacy/privacy/analysis/compute_noise_from_budget_lib.py index 81fb06a..f20d235 100644 --- a/tensorflow_privacy/privacy/analysis/compute_noise_from_budget_lib.py +++ b/tensorflow_privacy/privacy/analysis/compute_noise_from_budget_lib.py @@ -14,10 +14,6 @@ # ============================================================================== """Library for computing privacy values for DP-SGD.""" -from __future__ import absolute_import -from __future__ import division -from __future__ import print_function - import math from absl import app diff --git a/tensorflow_privacy/privacy/analysis/compute_noise_from_budget_test.py b/tensorflow_privacy/privacy/analysis/compute_noise_from_budget_test.py index c8a5a98..6f1ed79 100644 --- a/tensorflow_privacy/privacy/analysis/compute_noise_from_budget_test.py +++ b/tensorflow_privacy/privacy/analysis/compute_noise_from_budget_test.py @@ -13,10 +13,6 @@ # limitations under the License. # ============================================================================== -from __future__ import absolute_import -from __future__ import division -from __future__ import print_function - from absl.testing import absltest from absl.testing import parameterized diff --git a/tensorflow_privacy/privacy/analysis/rdp_accountant.py b/tensorflow_privacy/privacy/analysis/rdp_accountant.py index 342d2e5..2db5e9e 100644 --- a/tensorflow_privacy/privacy/analysis/rdp_accountant.py +++ b/tensorflow_privacy/privacy/analysis/rdp_accountant.py @@ -36,9 +36,6 @@ The example code would be: rdp += rdp_accountant.compute_rdp(q, sigma, T, orders) eps, _, opt_order = rdp_accountant.get_privacy_spent(rdp, target_delta=delta) """ -from __future__ import absolute_import -from __future__ import division -from __future__ import print_function import math import sys diff --git a/tensorflow_privacy/privacy/analysis/rdp_accountant_test.py b/tensorflow_privacy/privacy/analysis/rdp_accountant_test.py index 63983ad..01f3f3c 100644 --- a/tensorflow_privacy/privacy/analysis/rdp_accountant_test.py +++ b/tensorflow_privacy/privacy/analysis/rdp_accountant_test.py @@ -12,11 +12,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================== -"""Tests for rdp_accountant.py.""" - -from __future__ import absolute_import -from __future__ import division -from __future__ import print_function import math import sys diff --git a/tensorflow_privacy/privacy/analysis/tensor_buffer.py b/tensorflow_privacy/privacy/analysis/tensor_buffer.py index 92f93bc..5a5d272 100644 --- a/tensorflow_privacy/privacy/analysis/tensor_buffer.py +++ b/tensorflow_privacy/privacy/analysis/tensor_buffer.py @@ -13,10 +13,6 @@ # limitations under the License. """A lightweight buffer for maintaining tensors.""" -from __future__ import absolute_import -from __future__ import division -from __future__ import print_function - import tensorflow.compat.v1 as tf diff --git a/tensorflow_privacy/privacy/analysis/tensor_buffer_eager_test.py b/tensorflow_privacy/privacy/analysis/tensor_buffer_eager_test.py index ad921c7..22786a6 100644 --- a/tensorflow_privacy/privacy/analysis/tensor_buffer_eager_test.py +++ b/tensorflow_privacy/privacy/analysis/tensor_buffer_eager_test.py @@ -11,11 +11,6 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. -"""Tests for tensor_buffer in eager mode.""" - -from __future__ import absolute_import -from __future__ import division -from __future__ import print_function import tensorflow.compat.v1 as tf diff --git a/tensorflow_privacy/privacy/analysis/tensor_buffer_graph_test.py b/tensorflow_privacy/privacy/analysis/tensor_buffer_graph_test.py index 65265f4..8d7cfca 100644 --- a/tensorflow_privacy/privacy/analysis/tensor_buffer_graph_test.py +++ b/tensorflow_privacy/privacy/analysis/tensor_buffer_graph_test.py @@ -11,11 +11,6 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. -"""Tests for tensor_buffer in graph mode.""" - -from __future__ import absolute_import -from __future__ import division -from __future__ import print_function import tensorflow.compat.v1 as tf diff --git a/tensorflow_privacy/privacy/analysis/tree_aggregation_accountant.py b/tensorflow_privacy/privacy/analysis/tree_aggregation_accountant.py index 796a543..794dbb3 100644 --- a/tensorflow_privacy/privacy/analysis/tree_aggregation_accountant.py +++ b/tensorflow_privacy/privacy/analysis/tree_aggregation_accountant.py @@ -57,9 +57,6 @@ appearance of a same sample. For `target_delta`, the estimated epsilon is: max_participation, min_separation, orders) eps = rdp_accountant.get_privacy_spent(orders, rdp, target_delta)[0] """ -from __future__ import absolute_import -from __future__ import division -from __future__ import print_function import functools import math diff --git a/tensorflow_privacy/privacy/analysis/tree_aggregation_accountant_test.py b/tensorflow_privacy/privacy/analysis/tree_aggregation_accountant_test.py index 5dfe218..b60e06c 100644 --- a/tensorflow_privacy/privacy/analysis/tree_aggregation_accountant_test.py +++ b/tensorflow_privacy/privacy/analysis/tree_aggregation_accountant_test.py @@ -12,11 +12,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================== -"""Tests for rdp_accountant.py.""" - -from __future__ import absolute_import -from __future__ import division -from __future__ import print_function from absl.testing import parameterized import tensorflow as tf diff --git a/tensorflow_privacy/privacy/bolt_on/losses.py b/tensorflow_privacy/privacy/bolt_on/losses.py index d70b111..59766b8 100644 --- a/tensorflow_privacy/privacy/bolt_on/losses.py +++ b/tensorflow_privacy/privacy/bolt_on/losses.py @@ -13,10 +13,6 @@ # limitations under the License. """Loss functions for BoltOn method.""" -from __future__ import absolute_import -from __future__ import division -from __future__ import print_function - import tensorflow.compat.v1 as tf from tensorflow.compat.v1.python.framework import ops as _ops from tensorflow.compat.v1.python.keras import losses diff --git a/tensorflow_privacy/privacy/bolt_on/losses_test.py b/tensorflow_privacy/privacy/bolt_on/losses_test.py index 57effb8..bf99245 100644 --- a/tensorflow_privacy/privacy/bolt_on/losses_test.py +++ b/tensorflow_privacy/privacy/bolt_on/losses_test.py @@ -11,15 +11,11 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. -"""Unit testing for losses.""" - -from __future__ import absolute_import -from __future__ import division -from __future__ import print_function from contextlib import contextmanager # pylint: disable=g-importing-member from io import StringIO # pylint: disable=g-importing-member import sys + from absl.testing import parameterized import tensorflow.compat.v1 as tf from tensorflow.compat.v1.python.framework import test_util diff --git a/tensorflow_privacy/privacy/bolt_on/models.py b/tensorflow_privacy/privacy/bolt_on/models.py index 7a3df40..0d55897 100644 --- a/tensorflow_privacy/privacy/bolt_on/models.py +++ b/tensorflow_privacy/privacy/bolt_on/models.py @@ -13,9 +13,6 @@ # limitations under the License. """BoltOn model for Bolt-on method of differentially private ML.""" -from __future__ import absolute_import -from __future__ import division -from __future__ import print_function import tensorflow.compat.v1 as tf from tensorflow.compat.v1.python.framework import ops as _ops from tensorflow.compat.v1.python.keras import optimizers diff --git a/tensorflow_privacy/privacy/bolt_on/models_test.py b/tensorflow_privacy/privacy/bolt_on/models_test.py index 49ec663..2774532 100644 --- a/tensorflow_privacy/privacy/bolt_on/models_test.py +++ b/tensorflow_privacy/privacy/bolt_on/models_test.py @@ -11,11 +11,6 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. -"""Unit testing for models.""" - -from __future__ import absolute_import -from __future__ import division -from __future__ import print_function from absl.testing import parameterized import tensorflow.compat.v1 as tf diff --git a/tensorflow_privacy/privacy/bolt_on/optimizers.py b/tensorflow_privacy/privacy/bolt_on/optimizers.py index 6c45026..5029f73 100644 --- a/tensorflow_privacy/privacy/bolt_on/optimizers.py +++ b/tensorflow_privacy/privacy/bolt_on/optimizers.py @@ -13,10 +13,6 @@ # limitations under the License. """BoltOn Optimizer for Bolt-on method.""" -from __future__ import absolute_import -from __future__ import division -from __future__ import print_function - import tensorflow.compat.v1 as tf from tensorflow.compat.v1.python.keras.optimizer_v2 import optimizer_v2 from tensorflow.compat.v1.python.ops import math_ops diff --git a/tensorflow_privacy/privacy/bolt_on/optimizers_test.py b/tensorflow_privacy/privacy/bolt_on/optimizers_test.py index b7227cf..bd4727b 100644 --- a/tensorflow_privacy/privacy/bolt_on/optimizers_test.py +++ b/tensorflow_privacy/privacy/bolt_on/optimizers_test.py @@ -11,13 +11,9 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. -"""Unit testing for optimizers.""" - -from __future__ import absolute_import -from __future__ import division -from __future__ import print_function import unittest + from absl.testing import parameterized import tensorflow.compat.v1 as tf from tensorflow.compat.v1.python import ops as _ops diff --git a/tensorflow_privacy/privacy/dp_query/dp_query.py b/tensorflow_privacy/privacy/dp_query/dp_query.py index 298b45f..8e21c63 100644 --- a/tensorflow_privacy/privacy/dp_query/dp_query.py +++ b/tensorflow_privacy/privacy/dp_query/dp_query.py @@ -41,10 +41,6 @@ samples. In the common situation where the privacy mechanism remains unchanged throughout the entire training process, the global state is usually None. """ -from __future__ import absolute_import -from __future__ import division -from __future__ import print_function - import abc import collections diff --git a/tensorflow_privacy/privacy/dp_query/gaussian_query.py b/tensorflow_privacy/privacy/dp_query/gaussian_query.py index 3edd2fb..d382a5b 100644 --- a/tensorflow_privacy/privacy/dp_query/gaussian_query.py +++ b/tensorflow_privacy/privacy/dp_query/gaussian_query.py @@ -13,10 +13,6 @@ # limitations under the License. """Implements DPQuery interface for Gaussian sum queries.""" -from __future__ import absolute_import -from __future__ import division -from __future__ import print_function - import collections import distutils diff --git a/tensorflow_privacy/privacy/dp_query/gaussian_query_test.py b/tensorflow_privacy/privacy/dp_query/gaussian_query_test.py index ee76bf8..bfc142c 100644 --- a/tensorflow_privacy/privacy/dp_query/gaussian_query_test.py +++ b/tensorflow_privacy/privacy/dp_query/gaussian_query_test.py @@ -11,11 +11,6 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. -"""Tests for GaussianSumQuery.""" - -from __future__ import absolute_import -from __future__ import division -from __future__ import print_function from absl.testing import parameterized import numpy as np diff --git a/tensorflow_privacy/privacy/dp_query/nested_query.py b/tensorflow_privacy/privacy/dp_query/nested_query.py index b4e2247..b925b18 100644 --- a/tensorflow_privacy/privacy/dp_query/nested_query.py +++ b/tensorflow_privacy/privacy/dp_query/nested_query.py @@ -13,10 +13,6 @@ # limitations under the License. """Implements DPQuery interface for queries over nested structures.""" -from __future__ import absolute_import -from __future__ import division -from __future__ import print_function - import collections import tensorflow.compat.v1 as tf diff --git a/tensorflow_privacy/privacy/dp_query/nested_query_test.py b/tensorflow_privacy/privacy/dp_query/nested_query_test.py index 1e60fbe..ef461a2 100644 --- a/tensorflow_privacy/privacy/dp_query/nested_query_test.py +++ b/tensorflow_privacy/privacy/dp_query/nested_query_test.py @@ -11,11 +11,6 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. -"""Tests for NestedQuery.""" - -from __future__ import absolute_import -from __future__ import division -from __future__ import print_function import collections diff --git a/tensorflow_privacy/privacy/dp_query/no_privacy_query.py b/tensorflow_privacy/privacy/dp_query/no_privacy_query.py index 3840003..6fc97a1 100644 --- a/tensorflow_privacy/privacy/dp_query/no_privacy_query.py +++ b/tensorflow_privacy/privacy/dp_query/no_privacy_query.py @@ -13,10 +13,6 @@ # limitations under the License. """Implements DPQuery interface for no privacy average queries.""" -from __future__ import absolute_import -from __future__ import division -from __future__ import print_function - import tensorflow.compat.v1 as tf from tensorflow_privacy.privacy.analysis import dp_event diff --git a/tensorflow_privacy/privacy/dp_query/no_privacy_query_test.py b/tensorflow_privacy/privacy/dp_query/no_privacy_query_test.py index 64595b7..06dc655 100644 --- a/tensorflow_privacy/privacy/dp_query/no_privacy_query_test.py +++ b/tensorflow_privacy/privacy/dp_query/no_privacy_query_test.py @@ -12,12 +12,6 @@ # See the License for the specific language governing permissions and # limitations under the License. -"""Tests for NoPrivacyAverageQuery.""" - -from __future__ import absolute_import -from __future__ import division -from __future__ import print_function - from absl.testing import parameterized import tensorflow.compat.v1 as tf diff --git a/tensorflow_privacy/privacy/dp_query/normalized_query.py b/tensorflow_privacy/privacy/dp_query/normalized_query.py index 929f526..b76a493 100644 --- a/tensorflow_privacy/privacy/dp_query/normalized_query.py +++ b/tensorflow_privacy/privacy/dp_query/normalized_query.py @@ -13,10 +13,6 @@ # limitations under the License. """Implements DPQuery interface for normalized queries.""" -from __future__ import absolute_import -from __future__ import division -from __future__ import print_function - import collections import tensorflow.compat.v1 as tf diff --git a/tensorflow_privacy/privacy/dp_query/normalized_query_test.py b/tensorflow_privacy/privacy/dp_query/normalized_query_test.py index 2dd0157..c035c77 100644 --- a/tensorflow_privacy/privacy/dp_query/normalized_query_test.py +++ b/tensorflow_privacy/privacy/dp_query/normalized_query_test.py @@ -11,11 +11,6 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. -"""Tests for NormalizedQuery.""" - -from __future__ import absolute_import -from __future__ import division -from __future__ import print_function import tensorflow.compat.v1 as tf diff --git a/tensorflow_privacy/privacy/dp_query/quantile_adaptive_clip_sum_query.py b/tensorflow_privacy/privacy/dp_query/quantile_adaptive_clip_sum_query.py index 15a8b36..b551de9 100644 --- a/tensorflow_privacy/privacy/dp_query/quantile_adaptive_clip_sum_query.py +++ b/tensorflow_privacy/privacy/dp_query/quantile_adaptive_clip_sum_query.py @@ -13,10 +13,6 @@ # limitations under the License. """`DPQuery` for Gaussian sum queries with adaptive clipping.""" -from __future__ import absolute_import -from __future__ import division -from __future__ import print_function - import collections import tensorflow.compat.v1 as tf diff --git a/tensorflow_privacy/privacy/dp_query/quantile_adaptive_clip_sum_query_test.py b/tensorflow_privacy/privacy/dp_query/quantile_adaptive_clip_sum_query_test.py index 5979266..e14b8f4 100644 --- a/tensorflow_privacy/privacy/dp_query/quantile_adaptive_clip_sum_query_test.py +++ b/tensorflow_privacy/privacy/dp_query/quantile_adaptive_clip_sum_query_test.py @@ -11,11 +11,6 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. -"""Tests for QuantileAdaptiveClipSumQuery.""" - -from __future__ import absolute_import -from __future__ import division -from __future__ import print_function from absl.testing import parameterized diff --git a/tensorflow_privacy/privacy/dp_query/quantile_estimator_query.py b/tensorflow_privacy/privacy/dp_query/quantile_estimator_query.py index 0708016..e5ac1b4 100644 --- a/tensorflow_privacy/privacy/dp_query/quantile_estimator_query.py +++ b/tensorflow_privacy/privacy/dp_query/quantile_estimator_query.py @@ -13,10 +13,6 @@ # limitations under the License. """Implements DPQuery interface for quantile estimator.""" -from __future__ import absolute_import -from __future__ import division -from __future__ import print_function - import collections import tensorflow.compat.v1 as tf diff --git a/tensorflow_privacy/privacy/dp_query/quantile_estimator_query_test.py b/tensorflow_privacy/privacy/dp_query/quantile_estimator_query_test.py index fa3f03e..3b3e800 100644 --- a/tensorflow_privacy/privacy/dp_query/quantile_estimator_query_test.py +++ b/tensorflow_privacy/privacy/dp_query/quantile_estimator_query_test.py @@ -12,12 +12,6 @@ # See the License for the specific language governing permissions and # limitations under the License. -"""Tests for QuantileAdaptiveClipSumQuery.""" - -from __future__ import absolute_import -from __future__ import division -from __future__ import print_function - from absl.testing import parameterized import numpy as np diff --git a/tensorflow_privacy/privacy/dp_query/test_utils.py b/tensorflow_privacy/privacy/dp_query/test_utils.py index 81134f9..d13b8d8 100644 --- a/tensorflow_privacy/privacy/dp_query/test_utils.py +++ b/tensorflow_privacy/privacy/dp_query/test_utils.py @@ -16,10 +16,6 @@ Utility methods for testing private queries. """ -from __future__ import absolute_import -from __future__ import division -from __future__ import print_function - def run_query(query, records, global_state=None, weights=None): """Executes query on the given set of records as a single sample. diff --git a/tensorflow_privacy/privacy/estimators/binary_class_head.py b/tensorflow_privacy/privacy/estimators/binary_class_head.py index 259b553..7e90d94 100644 --- a/tensorflow_privacy/privacy/estimators/binary_class_head.py +++ b/tensorflow_privacy/privacy/estimators/binary_class_head.py @@ -13,10 +13,6 @@ # limitations under the License. """Binary class head for Estimator that allow integration with TF Privacy.""" -from __future__ import absolute_import -from __future__ import division -from __future__ import print_function - import tensorflow as tf from tensorflow.python.keras.utils import losses_utils # pylint: disable=g-direct-tensorflow-import from tensorflow_estimator.python.estimator import model_fn diff --git a/tensorflow_privacy/privacy/estimators/binary_class_head_test.py b/tensorflow_privacy/privacy/estimators/binary_class_head_test.py index ab56db7..1cf6998 100644 --- a/tensorflow_privacy/privacy/estimators/binary_class_head_test.py +++ b/tensorflow_privacy/privacy/estimators/binary_class_head_test.py @@ -11,13 +11,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. -"""Tests for DP-enabled binary class heads.""" -from __future__ import absolute_import -from __future__ import division -from __future__ import print_function - -# from absl.testing import parameterized import numpy as np import tensorflow as tf from tensorflow_privacy.privacy.estimators import binary_class_head diff --git a/tensorflow_privacy/privacy/estimators/dnn.py b/tensorflow_privacy/privacy/estimators/dnn.py index b3fece1..edbf2e6 100644 --- a/tensorflow_privacy/privacy/estimators/dnn.py +++ b/tensorflow_privacy/privacy/estimators/dnn.py @@ -13,10 +13,6 @@ # limitations under the License. """Estimator heads that allow integration with TF Privacy.""" -from __future__ import absolute_import -from __future__ import division -from __future__ import print_function - import tensorflow as tf from tensorflow_privacy.privacy.estimators import head_utils diff --git a/tensorflow_privacy/privacy/estimators/dnn_test.py b/tensorflow_privacy/privacy/estimators/dnn_test.py index 19b994e..214584e 100644 --- a/tensorflow_privacy/privacy/estimators/dnn_test.py +++ b/tensorflow_privacy/privacy/estimators/dnn_test.py @@ -11,13 +11,9 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. -"""Tests for DP-enabled DNNClassifier.""" - -from __future__ import absolute_import -from __future__ import division -from __future__ import print_function import functools + from absl.testing import parameterized import tensorflow as tf from tensorflow_privacy.privacy.estimators import dnn diff --git a/tensorflow_privacy/privacy/estimators/head_utils.py b/tensorflow_privacy/privacy/estimators/head_utils.py index 0b4723d..4a04fbc 100644 --- a/tensorflow_privacy/privacy/estimators/head_utils.py +++ b/tensorflow_privacy/privacy/estimators/head_utils.py @@ -13,10 +13,6 @@ # limitations under the License. """Estimator heads that allow integration with TF Privacy.""" -from __future__ import absolute_import -from __future__ import division -from __future__ import print_function - from tensorflow_privacy.privacy.estimators.binary_class_head import DPBinaryClassHead from tensorflow_privacy.privacy.estimators.multi_class_head import DPMultiClassHead diff --git a/tensorflow_privacy/privacy/estimators/multi_class_head.py b/tensorflow_privacy/privacy/estimators/multi_class_head.py index 2bbbe2d..5bd7e6c 100644 --- a/tensorflow_privacy/privacy/estimators/multi_class_head.py +++ b/tensorflow_privacy/privacy/estimators/multi_class_head.py @@ -13,10 +13,6 @@ # limitations under the License. """Multiclass head for Estimator that allow integration with TF Privacy.""" -from __future__ import absolute_import -from __future__ import division -from __future__ import print_function - import tensorflow as tf from tensorflow.python.keras.utils import losses_utils # pylint: disable=g-direct-tensorflow-import from tensorflow_estimator.python.estimator import model_fn diff --git a/tensorflow_privacy/privacy/estimators/multi_class_head_test.py b/tensorflow_privacy/privacy/estimators/multi_class_head_test.py index 2eca0da..b002561 100644 --- a/tensorflow_privacy/privacy/estimators/multi_class_head_test.py +++ b/tensorflow_privacy/privacy/estimators/multi_class_head_test.py @@ -11,11 +11,6 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. -"""Tests for DP-enabled binary class heads.""" - -from __future__ import absolute_import -from __future__ import division -from __future__ import print_function import numpy as np import tensorflow as tf diff --git a/tensorflow_privacy/privacy/estimators/multi_label_head.py b/tensorflow_privacy/privacy/estimators/multi_label_head.py index 3248177..9427ed3 100644 --- a/tensorflow_privacy/privacy/estimators/multi_label_head.py +++ b/tensorflow_privacy/privacy/estimators/multi_label_head.py @@ -13,10 +13,6 @@ # limitations under the License. """Multiclass head for Estimator that allow integration with TF Privacy.""" -from __future__ import absolute_import -from __future__ import division -from __future__ import print_function - import tensorflow as tf from tensorflow.python.keras.utils import losses_utils # pylint: disable=g-direct-tensorflow-import from tensorflow_estimator.python.estimator import model_fn diff --git a/tensorflow_privacy/privacy/estimators/multi_label_head_test.py b/tensorflow_privacy/privacy/estimators/multi_label_head_test.py index 98b95a0..659250b 100644 --- a/tensorflow_privacy/privacy/estimators/multi_label_head_test.py +++ b/tensorflow_privacy/privacy/estimators/multi_label_head_test.py @@ -11,11 +11,6 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. -"""Tests for DP-enabled binary class heads.""" - -from __future__ import absolute_import -from __future__ import division -from __future__ import print_function import numpy as np import tensorflow as tf diff --git a/tensorflow_privacy/privacy/estimators/test_utils.py b/tensorflow_privacy/privacy/estimators/test_utils.py index ea742df..0e749c3 100644 --- a/tensorflow_privacy/privacy/estimators/test_utils.py +++ b/tensorflow_privacy/privacy/estimators/test_utils.py @@ -13,10 +13,6 @@ # limitations under the License. """Helper functions for unit tests for DP-enabled Estimators.""" -from __future__ import absolute_import -from __future__ import division -from __future__ import print_function - import numpy as np import tensorflow as tf diff --git a/tensorflow_privacy/privacy/estimators/v1/dnn_test.py b/tensorflow_privacy/privacy/estimators/v1/dnn_test.py index 68a856e..2a83bb8 100644 --- a/tensorflow_privacy/privacy/estimators/v1/dnn_test.py +++ b/tensorflow_privacy/privacy/estimators/v1/dnn_test.py @@ -11,13 +11,9 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. -"""Tests for DP-enabled DNNClassifier.""" - -from __future__ import absolute_import -from __future__ import division -from __future__ import print_function import functools + from absl.testing import parameterized import tensorflow as tf from tensorflow_privacy.privacy.estimators import test_utils diff --git a/tensorflow_privacy/privacy/estimators/v1/head.py b/tensorflow_privacy/privacy/estimators/v1/head.py index 994ca6b..cf223eb 100644 --- a/tensorflow_privacy/privacy/estimators/v1/head.py +++ b/tensorflow_privacy/privacy/estimators/v1/head.py @@ -13,10 +13,6 @@ # limitations under the License. """Estimator v1 heads that allow integration with TF Privacy.""" -from __future__ import absolute_import -from __future__ import division -from __future__ import print_function - import tensorflow as tf from tensorflow.python.ops import lookup_ops # pylint: disable=g-direct-tensorflow-import diff --git a/tensorflow_privacy/privacy/estimators/v1/head_test.py b/tensorflow_privacy/privacy/estimators/v1/head_test.py index db3d4ae..5238912 100644 --- a/tensorflow_privacy/privacy/estimators/v1/head_test.py +++ b/tensorflow_privacy/privacy/estimators/v1/head_test.py @@ -11,11 +11,6 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. -"""Tests for DP-enabled binary class heads.""" - -from __future__ import absolute_import -from __future__ import division -from __future__ import print_function from absl.testing import parameterized diff --git a/tensorflow_privacy/privacy/keras_models/dp_keras_model_test.py b/tensorflow_privacy/privacy/keras_models/dp_keras_model_test.py index 27c9d61..8e51aa4 100644 --- a/tensorflow_privacy/privacy/keras_models/dp_keras_model_test.py +++ b/tensorflow_privacy/privacy/keras_models/dp_keras_model_test.py @@ -11,11 +11,6 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. -"""Tests for DP Keras Model.""" - -from __future__ import absolute_import -from __future__ import division -from __future__ import print_function from absl.testing import parameterized diff --git a/tensorflow_privacy/privacy/optimizers/dp_optimizer.py b/tensorflow_privacy/privacy/optimizers/dp_optimizer.py index 336c1d2..0f962a5 100644 --- a/tensorflow_privacy/privacy/optimizers/dp_optimizer.py +++ b/tensorflow_privacy/privacy/optimizers/dp_optimizer.py @@ -13,10 +13,6 @@ # limitations under the License. """Differentially private optimizers for TensorFlow.""" -from __future__ import absolute_import -from __future__ import division -from __future__ import print_function - from absl import logging import tensorflow.compat.v1 as tf diff --git a/tensorflow_privacy/privacy/optimizers/dp_optimizer_eager_test.py b/tensorflow_privacy/privacy/optimizers/dp_optimizer_eager_test.py index 22906b2..d6f314d 100644 --- a/tensorflow_privacy/privacy/optimizers/dp_optimizer_eager_test.py +++ b/tensorflow_privacy/privacy/optimizers/dp_optimizer_eager_test.py @@ -11,11 +11,6 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. -"""Tests for differentially private optimizers.""" - -from __future__ import absolute_import -from __future__ import division -from __future__ import print_function from absl.testing import parameterized import numpy as np diff --git a/tensorflow_privacy/privacy/optimizers/dp_optimizer_keras.py b/tensorflow_privacy/privacy/optimizers/dp_optimizer_keras.py index dc01e2d..4719ec2 100644 --- a/tensorflow_privacy/privacy/optimizers/dp_optimizer_keras.py +++ b/tensorflow_privacy/privacy/optimizers/dp_optimizer_keras.py @@ -14,10 +14,6 @@ # ============================================================================== """Differentially private version of Keras optimizer v2.""" -from __future__ import absolute_import -from __future__ import division -from __future__ import print_function - import tensorflow as tf from tensorflow_privacy.privacy.dp_query import gaussian_query diff --git a/tensorflow_privacy/privacy/optimizers/dp_optimizer_keras_test.py b/tensorflow_privacy/privacy/optimizers/dp_optimizer_keras_test.py index b4013bf..293d6e9 100644 --- a/tensorflow_privacy/privacy/optimizers/dp_optimizer_keras_test.py +++ b/tensorflow_privacy/privacy/optimizers/dp_optimizer_keras_test.py @@ -11,11 +11,6 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. -"""Tests for dp_optimizer_keras.py.""" - -from __future__ import absolute_import -from __future__ import division -from __future__ import print_function from absl.testing import parameterized import numpy as np diff --git a/tensorflow_privacy/privacy/optimizers/dp_optimizer_keras_vectorized.py b/tensorflow_privacy/privacy/optimizers/dp_optimizer_keras_vectorized.py index 71321e4..c84e060 100644 --- a/tensorflow_privacy/privacy/optimizers/dp_optimizer_keras_vectorized.py +++ b/tensorflow_privacy/privacy/optimizers/dp_optimizer_keras_vectorized.py @@ -14,10 +14,6 @@ # ============================================================================== """Differentially private version of Keras optimizer v2.""" -from __future__ import absolute_import -from __future__ import division -from __future__ import print_function - import tensorflow as tf from tensorflow_privacy.privacy.dp_query import gaussian_query diff --git a/tensorflow_privacy/privacy/optimizers/dp_optimizer_test.py b/tensorflow_privacy/privacy/optimizers/dp_optimizer_test.py index 129f722..611464a 100644 --- a/tensorflow_privacy/privacy/optimizers/dp_optimizer_test.py +++ b/tensorflow_privacy/privacy/optimizers/dp_optimizer_test.py @@ -11,11 +11,6 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. -"""Tests for differentially private optimizers.""" - -from __future__ import absolute_import -from __future__ import division -from __future__ import print_function import os diff --git a/tensorflow_privacy/privacy/optimizers/dp_optimizer_vectorized.py b/tensorflow_privacy/privacy/optimizers/dp_optimizer_vectorized.py index 0f2dffb..0155914 100644 --- a/tensorflow_privacy/privacy/optimizers/dp_optimizer_vectorized.py +++ b/tensorflow_privacy/privacy/optimizers/dp_optimizer_vectorized.py @@ -13,10 +13,6 @@ # limitations under the License. """Vectorized differentially private optimizers for TensorFlow.""" -from __future__ import absolute_import -from __future__ import division -from __future__ import print_function - from absl import logging import tensorflow.compat.v1 as tf diff --git a/tensorflow_privacy/privacy/optimizers/dp_optimizer_vectorized_test.py b/tensorflow_privacy/privacy/optimizers/dp_optimizer_vectorized_test.py index e4d9633..6d326fd 100644 --- a/tensorflow_privacy/privacy/optimizers/dp_optimizer_vectorized_test.py +++ b/tensorflow_privacy/privacy/optimizers/dp_optimizer_vectorized_test.py @@ -11,11 +11,6 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. -"""Tests for differentially private optimizers.""" - -from __future__ import absolute_import -from __future__ import division -from __future__ import print_function from absl.testing import parameterized import mock diff --git a/tensorflow_privacy/v1/__init__.py b/tensorflow_privacy/v1/__init__.py index 7bce1a9..44a8a69 100644 --- a/tensorflow_privacy/v1/__init__.py +++ b/tensorflow_privacy/v1/__init__.py @@ -17,10 +17,6 @@ This module includes classes designed to be compatible with TF1, based on `tf.compat.v1.train.Optimizer` and `tf.estimator.Estimator`. """ -from __future__ import absolute_import -from __future__ import division -from __future__ import print_function - import sys # pylint: disable=g-import-not-at-top diff --git a/tutorials/bolton_tutorial.py b/tutorials/bolton_tutorial.py index 374a39c..507b24b 100644 --- a/tutorials/bolton_tutorial.py +++ b/tutorials/bolton_tutorial.py @@ -12,9 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. """Tutorial for bolt_on module, the model and the optimizer.""" -from __future__ import absolute_import -from __future__ import division -from __future__ import print_function + import tensorflow.compat.v1 as tf # pylint: disable=wrong-import-position from tensorflow_privacy.privacy.bolt_on import losses # pylint: disable=wrong-import-position from tensorflow_privacy.privacy.bolt_on import models # pylint: disable=wrong-import-position diff --git a/tutorials/lm_dpsgd_tutorial.py b/tutorials/lm_dpsgd_tutorial.py index e1e2765..44ac18b 100644 --- a/tutorials/lm_dpsgd_tutorial.py +++ b/tutorials/lm_dpsgd_tutorial.py @@ -30,15 +30,10 @@ using the exposure metric of https://arxiv.org/abs/1802.08232. This example is decribed in more details in this post: https://goo.gl/UKr7vH """ -from __future__ import absolute_import -from __future__ import division -from __future__ import print_function - import os from absl import app from absl import flags - import numpy as np import tensorflow.compat.v1 as tf import tensorflow_datasets as tfds diff --git a/tutorials/mnist_dpsgd_tutorial.py b/tutorials/mnist_dpsgd_tutorial.py index 51b0c40..ebbbd22 100644 --- a/tutorials/mnist_dpsgd_tutorial.py +++ b/tutorials/mnist_dpsgd_tutorial.py @@ -11,19 +11,13 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. - """Train a CNN on MNIST with differentially private SGD optimizer.""" -from __future__ import absolute_import -from __future__ import division -from __future__ import print_function - import time from absl import app from absl import flags from absl import logging - import tensorflow.compat.v1 as tf from tensorflow_privacy.privacy.analysis import compute_dp_sgd_privacy_lib diff --git a/tutorials/mnist_dpsgd_tutorial_common.py b/tutorials/mnist_dpsgd_tutorial_common.py index 4784939..78bcce4 100644 --- a/tutorials/mnist_dpsgd_tutorial_common.py +++ b/tutorials/mnist_dpsgd_tutorial_common.py @@ -13,11 +13,6 @@ # limitations under the License. """Common tools for DP-SGD MNIST tutorials.""" -# These are not necessary in a Python 3-only module. -from __future__ import absolute_import -from __future__ import division -from __future__ import print_function - import tensorflow.compat.v1 as tf import tensorflow_datasets as tfds diff --git a/tutorials/mnist_dpsgd_tutorial_eager.py b/tutorials/mnist_dpsgd_tutorial_eager.py index 1c4060f..57fd702 100644 --- a/tutorials/mnist_dpsgd_tutorial_eager.py +++ b/tutorials/mnist_dpsgd_tutorial_eager.py @@ -12,13 +12,9 @@ # See the License for the specific language governing permissions and # limitations under the License. """Training a CNN on MNIST in TF Eager mode with DP-SGD optimizer.""" -from __future__ import absolute_import -from __future__ import division -from __future__ import print_function from absl import app from absl import flags - import numpy as np import tensorflow.compat.v1 as tf diff --git a/tutorials/mnist_dpsgd_tutorial_keras.py b/tutorials/mnist_dpsgd_tutorial_keras.py index 7e78a6d..54ad377 100644 --- a/tutorials/mnist_dpsgd_tutorial_keras.py +++ b/tutorials/mnist_dpsgd_tutorial_keras.py @@ -13,10 +13,6 @@ # limitations under the License. """Training a CNN on MNIST with Keras and the DP SGD optimizer.""" -from __future__ import absolute_import -from __future__ import division -from __future__ import print_function - from absl import app from absl import flags from absl import logging diff --git a/tutorials/mnist_dpsgd_tutorial_keras_model.py b/tutorials/mnist_dpsgd_tutorial_keras_model.py index de59a09..4cbfe1b 100644 --- a/tutorials/mnist_dpsgd_tutorial_keras_model.py +++ b/tutorials/mnist_dpsgd_tutorial_keras_model.py @@ -13,14 +13,9 @@ # limitations under the License. """Training a CNN on MNIST with Keras and the DP SGD optimizer.""" -from __future__ import absolute_import -from __future__ import division -from __future__ import print_function - from absl import app from absl import flags from absl import logging - import numpy as np import tensorflow as tf diff --git a/tutorials/mnist_dpsgd_tutorial_tpu.py b/tutorials/mnist_dpsgd_tutorial_tpu.py index 0df6f40..e87f129 100644 --- a/tutorials/mnist_dpsgd_tutorial_tpu.py +++ b/tutorials/mnist_dpsgd_tutorial_tpu.py @@ -11,20 +11,14 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. - """Train a CNN on MNIST with DP-SGD optimizer on TPUs.""" -from __future__ import absolute_import -from __future__ import division -from __future__ import print_function - import math import time from absl import app from absl import flags from absl import logging - import tensorflow.compat.v1 as tf from tensorflow_privacy.privacy.analysis import compute_dp_sgd_privacy_lib diff --git a/tutorials/mnist_dpsgd_tutorial_vectorized.py b/tutorials/mnist_dpsgd_tutorial_vectorized.py index c282c21..2c7b2d7 100644 --- a/tutorials/mnist_dpsgd_tutorial_vectorized.py +++ b/tutorials/mnist_dpsgd_tutorial_vectorized.py @@ -11,16 +11,10 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. - """Training a CNN on MNIST with vectorized DP-SGD optimizer.""" -from __future__ import absolute_import -from __future__ import division -from __future__ import print_function - from absl import app from absl import flags - import numpy as np import tensorflow.compat.v1 as tf diff --git a/tutorials/mnist_lr_tutorial.py b/tutorials/mnist_lr_tutorial.py index 8fd61d9..aae4825 100644 --- a/tutorials/mnist_lr_tutorial.py +++ b/tutorials/mnist_lr_tutorial.py @@ -21,10 +21,6 @@ pp. 521-532. IEEE, 2018. https://arxiv.org/abs/1808.06651. """ -from __future__ import absolute_import -from __future__ import division -from __future__ import print_function - import math from absl import app diff --git a/tutorials/movielens_tutorial.py b/tutorials/movielens_tutorial.py index 5cd9cbb..268cf00 100644 --- a/tutorials/movielens_tutorial.py +++ b/tutorials/movielens_tutorial.py @@ -14,13 +14,8 @@ # ============================================================================= """Training a deep NN on MovieLens with differentially private Adam optimizer.""" -from __future__ import absolute_import -from __future__ import division -from __future__ import print_function - from absl import app from absl import flags - import numpy as np import pandas as pd from scipy import stats diff --git a/tutorials/walkthrough/mnist_scratch.py b/tutorials/walkthrough/mnist_scratch.py index 9399e60..b1622de 100644 --- a/tutorials/walkthrough/mnist_scratch.py +++ b/tutorials/walkthrough/mnist_scratch.py @@ -11,12 +11,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. - - """Scratchpad for training a CNN on MNIST with DPSGD.""" -from __future__ import absolute_import -from __future__ import division -from __future__ import print_function import numpy as np import tensorflow.compat.v1 as tf