From c0bd19365bc143f0703e0fb270730fe546988f23 Mon Sep 17 00:00:00 2001 From: Christopher Choquette Choo Date: Wed, 31 Jul 2019 10:52:41 -0400 Subject: [PATCH] Refactoring bolton package to bolt_on only in code usages. --- privacy/__init__.py | 10 +++++----- privacy/{bolton => bolt_on}/README.md | 0 privacy/{bolton => bolt_on}/__init__.py | 8 ++++---- privacy/{bolton => bolt_on}/losses.py | 0 privacy/{bolton => bolt_on}/losses_test.py | 6 +++--- privacy/{bolton => bolt_on}/models.py | 4 ++-- privacy/{bolton => bolt_on}/models_test.py | 6 +++--- privacy/{bolton => bolt_on}/optimizers.py | 2 +- privacy/{bolton => bolt_on}/optimizers_test.py | 4 ++-- tutorials/bolton_tutorial.py | 6 +++--- 10 files changed, 23 insertions(+), 23 deletions(-) rename privacy/{bolton => bolt_on}/README.md (100%) rename privacy/{bolton => bolt_on}/__init__.py (75%) rename privacy/{bolton => bolt_on}/losses.py (100%) rename privacy/{bolton => bolt_on}/losses_test.py (98%) rename privacy/{bolton => bolt_on}/models.py (99%) rename privacy/{bolton => bolt_on}/models_test.py (99%) rename privacy/{bolton => bolt_on}/optimizers.py (99%) rename privacy/{bolton => bolt_on}/optimizers_test.py (99%) diff --git a/privacy/__init__.py b/privacy/__init__.py index 94add1e..aab6e94 100644 --- a/privacy/__init__.py +++ b/privacy/__init__.py @@ -42,8 +42,8 @@ else: from privacy.optimizers.dp_optimizer import DPGradientDescentGaussianOptimizer from privacy.optimizers.dp_optimizer import DPGradientDescentOptimizer - from privacy.bolton.models import BoltOnModel - from privacy.bolton.optimizers import BoltOn - from privacy.bolton.losses import StrongConvexMixin - from privacy.bolton.losses import StrongConvexBinaryCrossentropy - from privacy.bolton.losses import StrongConvexHuber + from privacy.bolt_on.models import BoltOnModel + from privacy.bolt_on.optimizers import BoltOn + from privacy.bolt_on.losses import StrongConvexMixin + from privacy.bolt_on.losses import StrongConvexBinaryCrossentropy + from privacy.bolt_on.losses import StrongConvexHuber diff --git a/privacy/bolton/README.md b/privacy/bolt_on/README.md similarity index 100% rename from privacy/bolton/README.md rename to privacy/bolt_on/README.md diff --git a/privacy/bolton/__init__.py b/privacy/bolt_on/__init__.py similarity index 75% rename from privacy/bolton/__init__.py rename to privacy/bolt_on/__init__.py index bc7a027..52b1b29 100644 --- a/privacy/bolton/__init__.py +++ b/privacy/bolt_on/__init__.py @@ -23,7 +23,7 @@ if LooseVersion(tf.__version__) < LooseVersion("2.0.0"): if hasattr(sys, "skip_tf_privacy_import"): # Useful for standalone scripts. pass else: - from privacy.bolton.models import BoltOnModel # pylint: disable=g-import-not-at-top - from privacy.bolton.optimizers import BoltOn # pylint: disable=g-import-not-at-top - from privacy.bolton.losses import StrongConvexHuber # pylint: disable=g-import-not-at-top - from privacy.bolton.losses import StrongConvexBinaryCrossentropy # pylint: disable=g-import-not-at-top + from privacy.bolt_on.models import BoltOnModel # pylint: disable=g-import-not-at-top + from privacy.bolt_on.optimizers import BoltOn # pylint: disable=g-import-not-at-top + from privacy.bolt_on.losses import StrongConvexHuber # pylint: disable=g-import-not-at-top + from privacy.bolt_on.losses import StrongConvexBinaryCrossentropy # pylint: disable=g-import-not-at-top diff --git a/privacy/bolton/losses.py b/privacy/bolt_on/losses.py similarity index 100% rename from privacy/bolton/losses.py rename to privacy/bolt_on/losses.py diff --git a/privacy/bolton/losses_test.py b/privacy/bolt_on/losses_test.py similarity index 98% rename from privacy/bolton/losses_test.py rename to privacy/bolt_on/losses_test.py index ff8137c..3d88190 100644 --- a/privacy/bolton/losses_test.py +++ b/privacy/bolt_on/losses_test.py @@ -25,9 +25,9 @@ import tensorflow as tf from tensorflow.python.framework import test_util from tensorflow.python.keras import keras_parameterized from tensorflow.python.keras.regularizers import L1L2 -from privacy.bolton.losses import StrongConvexBinaryCrossentropy -from privacy.bolton.losses import StrongConvexHuber -from privacy.bolton.losses import StrongConvexMixin +from privacy.bolt_on.losses import StrongConvexBinaryCrossentropy +from privacy.bolt_on.losses import StrongConvexHuber +from privacy.bolt_on.losses import StrongConvexMixin @contextmanager diff --git a/privacy/bolton/models.py b/privacy/bolt_on/models.py similarity index 99% rename from privacy/bolton/models.py rename to privacy/bolt_on/models.py index ad0f59c..98f2167 100644 --- a/privacy/bolton/models.py +++ b/privacy/bolt_on/models.py @@ -20,8 +20,8 @@ import tensorflow as tf from tensorflow.python.framework import ops as _ops from tensorflow.python.keras import optimizers from tensorflow.python.keras.models import Model -from privacy.bolton.losses import StrongConvexMixin -from privacy.bolton.optimizers import BoltOn +from privacy.bolt_on.losses import StrongConvexMixin +from privacy.bolt_on.optimizers import BoltOn class BoltOnModel(Model): # pylint: disable=abstract-method diff --git a/privacy/bolton/models_test.py b/privacy/bolt_on/models_test.py similarity index 99% rename from privacy/bolton/models_test.py rename to privacy/bolt_on/models_test.py index b252312..522f686 100644 --- a/privacy/bolton/models_test.py +++ b/privacy/bolt_on/models_test.py @@ -24,9 +24,9 @@ from tensorflow.python.keras import keras_parameterized from tensorflow.python.keras import losses from tensorflow.python.keras.optimizer_v2.optimizer_v2 import OptimizerV2 from tensorflow.python.keras.regularizers import L1L2 -from privacy.bolton import models -from privacy.bolton.losses import StrongConvexMixin -from privacy.bolton.optimizers import BoltOn +from privacy.bolt_on import models +from privacy.bolt_on.losses import StrongConvexMixin +from privacy.bolt_on.optimizers import BoltOn class TestLoss(losses.Loss, StrongConvexMixin): diff --git a/privacy/bolton/optimizers.py b/privacy/bolt_on/optimizers.py similarity index 99% rename from privacy/bolton/optimizers.py rename to privacy/bolt_on/optimizers.py index f5aa23e..97d1aba 100644 --- a/privacy/bolton/optimizers.py +++ b/privacy/bolt_on/optimizers.py @@ -20,7 +20,7 @@ from __future__ import print_function import tensorflow as tf from tensorflow.python.keras.optimizer_v2 import optimizer_v2 from tensorflow.python.ops import math_ops -from privacy.bolton.losses import StrongConvexMixin +from privacy.bolt_on.losses import StrongConvexMixin _accepted_distributions = ['laplace'] # implemented distributions for noising diff --git a/privacy/bolton/optimizers_test.py b/privacy/bolt_on/optimizers_test.py similarity index 99% rename from privacy/bolton/optimizers_test.py rename to privacy/bolt_on/optimizers_test.py index abfffdd..731d97d 100644 --- a/privacy/bolton/optimizers_test.py +++ b/privacy/bolt_on/optimizers_test.py @@ -28,8 +28,8 @@ from tensorflow.python.keras.models import Model from tensorflow.python.keras.optimizer_v2.optimizer_v2 import OptimizerV2 from tensorflow.python.keras.regularizers import L1L2 from tensorflow.python.platform import test -from privacy.bolton import optimizers as opt -from privacy.bolton.losses import StrongConvexMixin +from privacy.bolt_on import optimizers as opt +from privacy.bolt_on.losses import StrongConvexMixin class TestModel(Model): # pylint: disable=abstract-method diff --git a/tutorials/bolton_tutorial.py b/tutorials/bolton_tutorial.py index c56f9bf..5a3b748 100644 --- a/tutorials/bolton_tutorial.py +++ b/tutorials/bolton_tutorial.py @@ -16,9 +16,9 @@ from __future__ import absolute_import from __future__ import division from __future__ import print_function import tensorflow as tf # pylint: disable=wrong-import-position -from privacy.bolton import losses # pylint: disable=wrong-import-position -from privacy.bolton import models # pylint: disable=wrong-import-position -from privacy.bolton.optimizers import BoltOn # pylint: disable=wrong-import-position +from privacy.bolt_on import losses # pylint: disable=wrong-import-position +from privacy.bolt_on import models # pylint: disable=wrong-import-position +from privacy.bolt_on.optimizers import BoltOn # pylint: disable=wrong-import-position # ------- # First, we will create a binary classification dataset with a single output # dimension. The samples for each label are repeated data points at different