Explicitly replace "import tensorflow" with "tensorflow.compat.v1"

PiperOrigin-RevId: 290355582
This commit is contained in:
Yanhua Sun 2020-01-17 15:39:43 -08:00 committed by Steve Chien
parent a8a2d91795
commit 856eda3aa1
33 changed files with 60 additions and 60 deletions

View file

@ -20,7 +20,7 @@ from __future__ import print_function
import collections import collections
import numpy as np import numpy as np
import tensorflow as tf import tensorflow.compat.v1 as tf
from tensorflow_privacy.privacy.analysis import tensor_buffer from tensorflow_privacy.privacy.analysis import tensor_buffer
from tensorflow_privacy.privacy.dp_query import dp_query from tensorflow_privacy.privacy.dp_query import dp_query

View file

@ -18,7 +18,7 @@ from __future__ import absolute_import
from __future__ import division from __future__ import division
from __future__ import print_function from __future__ import print_function
import tensorflow as tf import tensorflow.compat.v1 as tf
from tensorflow_privacy.privacy.analysis import privacy_ledger from tensorflow_privacy.privacy.analysis import privacy_ledger
from tensorflow_privacy.privacy.dp_query import gaussian_query from tensorflow_privacy.privacy.dp_query import gaussian_query

View file

@ -17,7 +17,7 @@ from __future__ import absolute_import
from __future__ import division from __future__ import division
from __future__ import print_function from __future__ import print_function
import tensorflow as tf import tensorflow.compat.v1 as tf
class TensorBuffer(object): class TensorBuffer(object):

View file

@ -17,7 +17,7 @@ from __future__ import absolute_import
from __future__ import division from __future__ import division
from __future__ import print_function from __future__ import print_function
import tensorflow as tf import tensorflow.compat.v1 as tf
from tensorflow_privacy.privacy.analysis import tensor_buffer from tensorflow_privacy.privacy.analysis import tensor_buffer

View file

@ -17,7 +17,7 @@ from __future__ import absolute_import
from __future__ import division from __future__ import division
from __future__ import print_function from __future__ import print_function
import tensorflow as tf import tensorflow.compat.v1 as tf
from tensorflow_privacy.privacy.analysis import tensor_buffer from tensorflow_privacy.privacy.analysis import tensor_buffer

View file

@ -14,7 +14,7 @@
"""BoltOn Method for privacy.""" """BoltOn Method for privacy."""
import sys import sys
from distutils.version import LooseVersion from distutils.version import LooseVersion
import tensorflow as tf import tensorflow.compat.v1 as tf
if LooseVersion(tf.__version__) < LooseVersion("2.0.0"): if LooseVersion(tf.__version__) < LooseVersion("2.0.0"):
raise ImportError("Please upgrade your version " raise ImportError("Please upgrade your version "

View file

@ -17,12 +17,12 @@ from __future__ import absolute_import
from __future__ import division from __future__ import division
from __future__ import print_function from __future__ import print_function
import tensorflow as tf import tensorflow.compat.v1 as tf
from tensorflow.python.framework import ops as _ops from tensorflow.compat.v1.python.framework import ops as _ops
from tensorflow.python.keras import losses from tensorflow.compat.v1.python.keras import losses
from tensorflow.python.keras.regularizers import L1L2 from tensorflow.compat.v1.python.keras.regularizers import L1L2
from tensorflow.python.keras.utils import losses_utils from tensorflow.compat.v1.python.keras.utils import losses_utils
from tensorflow.python.platform import tf_logging as logging from tensorflow.compat.v1.python.platform import tf_logging as logging
class StrongConvexMixin: # pylint: disable=old-style-class class StrongConvexMixin: # pylint: disable=old-style-class

View file

@ -21,10 +21,10 @@ from contextlib import contextmanager # pylint: disable=g-importing-member
from io import StringIO # pylint: disable=g-importing-member from io import StringIO # pylint: disable=g-importing-member
import sys import sys
from absl.testing import parameterized from absl.testing import parameterized
import tensorflow as tf import tensorflow.compat.v1 as tf
from tensorflow.python.framework import test_util from tensorflow.compat.v1.python.framework import test_util
from tensorflow.python.keras import keras_parameterized from tensorflow.compat.v1.python.keras import keras_parameterized
from tensorflow.python.keras.regularizers import L1L2 from tensorflow.compat.v1.python.keras.regularizers import L1L2
from tensorflow_privacy.privacy.bolt_on.losses import StrongConvexBinaryCrossentropy from tensorflow_privacy.privacy.bolt_on.losses import StrongConvexBinaryCrossentropy
from tensorflow_privacy.privacy.bolt_on.losses import StrongConvexHuber from tensorflow_privacy.privacy.bolt_on.losses import StrongConvexHuber
from tensorflow_privacy.privacy.bolt_on.losses import StrongConvexMixin from tensorflow_privacy.privacy.bolt_on.losses import StrongConvexMixin

View file

@ -16,10 +16,10 @@
from __future__ import absolute_import from __future__ import absolute_import
from __future__ import division from __future__ import division
from __future__ import print_function from __future__ import print_function
import tensorflow as tf import tensorflow.compat.v1 as tf
from tensorflow.python.framework import ops as _ops from tensorflow.compat.v1.python.framework import ops as _ops
from tensorflow.python.keras import optimizers from tensorflow.compat.v1.python.keras import optimizers
from tensorflow.python.keras.models import Model from tensorflow.compat.v1.python.keras.models import Model
from tensorflow_privacy.privacy.bolt_on.losses import StrongConvexMixin from tensorflow_privacy.privacy.bolt_on.losses import StrongConvexMixin
from tensorflow_privacy.privacy.bolt_on.optimizers import BoltOn from tensorflow_privacy.privacy.bolt_on.optimizers import BoltOn

View file

@ -18,12 +18,12 @@ from __future__ import division
from __future__ import print_function from __future__ import print_function
from absl.testing import parameterized from absl.testing import parameterized
import tensorflow as tf import tensorflow.compat.v1 as tf
from tensorflow.python.framework import ops as _ops from tensorflow.compat.v1.python.framework import ops as _ops
from tensorflow.python.keras import keras_parameterized from tensorflow.compat.v1.python.keras import keras_parameterized
from tensorflow.python.keras import losses from tensorflow.compat.v1.python.keras import losses
from tensorflow.python.keras.optimizer_v2.optimizer_v2 import OptimizerV2 from tensorflow.compat.v1.python.keras.optimizer_v2.optimizer_v2 import OptimizerV2
from tensorflow.python.keras.regularizers import L1L2 from tensorflow.compat.v1.python.keras.regularizers import L1L2
from tensorflow_privacy.privacy.bolt_on import models from tensorflow_privacy.privacy.bolt_on import models
from tensorflow_privacy.privacy.bolt_on.losses import StrongConvexMixin from tensorflow_privacy.privacy.bolt_on.losses import StrongConvexMixin
from tensorflow_privacy.privacy.bolt_on.optimizers import BoltOn from tensorflow_privacy.privacy.bolt_on.optimizers import BoltOn

View file

@ -17,9 +17,9 @@ from __future__ import absolute_import
from __future__ import division from __future__ import division
from __future__ import print_function from __future__ import print_function
import tensorflow as tf import tensorflow.compat.v1 as tf
from tensorflow.python.keras.optimizer_v2 import optimizer_v2 from tensorflow.compat.v1.python.keras.optimizer_v2 import optimizer_v2
from tensorflow.python.ops import math_ops from tensorflow.compat.v1.python.ops import math_ops
from tensorflow_privacy.privacy.bolt_on.losses import StrongConvexMixin from tensorflow_privacy.privacy.bolt_on.losses import StrongConvexMixin
_accepted_distributions = ['laplace'] # implemented distributions for noising _accepted_distributions = ['laplace'] # implemented distributions for noising

View file

@ -19,16 +19,16 @@ from __future__ import print_function
import unittest import unittest
from absl.testing import parameterized from absl.testing import parameterized
import tensorflow as tf import tensorflow.compat.v1 as tf
from tensorflow.python import ops as _ops from tensorflow.compat.v1.python import ops as _ops
from tensorflow.python.framework import test_util from tensorflow.compat.v1.python.framework import test_util
from tensorflow.python.keras import keras_parameterized from tensorflow.compat.v1.python.keras import keras_parameterized
from tensorflow.python.keras import losses from tensorflow.compat.v1.python.keras import losses
from tensorflow.python.keras.initializers import constant from tensorflow.compat.v1.python.keras.initializers import constant
from tensorflow.python.keras.models import Model from tensorflow.compat.v1.python.keras.models import Model
from tensorflow.python.keras.optimizer_v2.optimizer_v2 import OptimizerV2 from tensorflow.compat.v1.python.keras.optimizer_v2.optimizer_v2 import OptimizerV2
from tensorflow.python.keras.regularizers import L1L2 from tensorflow.compat.v1.python.keras.regularizers import L1L2
from tensorflow.python.platform import test from tensorflow.compat.v1.python.platform import test
from tensorflow_privacy.privacy.bolt_on import optimizers as opt from tensorflow_privacy.privacy.bolt_on import optimizers as opt
from tensorflow_privacy.privacy.bolt_on.losses import StrongConvexMixin from tensorflow_privacy.privacy.bolt_on.losses import StrongConvexMixin

View file

@ -48,7 +48,7 @@ from __future__ import print_function
import abc import abc
import tensorflow as tf import tensorflow.compat.v1 as tf
class DPQuery(object): class DPQuery(object):

View file

@ -22,7 +22,7 @@ from __future__ import print_function
import collections import collections
from distutils.version import LooseVersion from distutils.version import LooseVersion
import tensorflow as tf import tensorflow.compat.v1 as tf
from tensorflow_privacy.privacy.dp_query import dp_query from tensorflow_privacy.privacy.dp_query import dp_query
from tensorflow_privacy.privacy.dp_query import normalized_query from tensorflow_privacy.privacy.dp_query import normalized_query

View file

@ -21,7 +21,7 @@ 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 from six.moves import xrange
import tensorflow 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
from tensorflow_privacy.privacy.dp_query import test_utils from tensorflow_privacy.privacy.dp_query import test_utils

View file

@ -21,7 +21,7 @@ from __future__ import print_function
from absl.testing import parameterized from absl.testing import parameterized
import numpy as np import numpy as np
import tensorflow 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
from tensorflow_privacy.privacy.dp_query import nested_query from tensorflow_privacy.privacy.dp_query import nested_query

View file

@ -17,7 +17,7 @@ from __future__ import absolute_import
from __future__ import division from __future__ import division
from __future__ import print_function from __future__ import print_function
import tensorflow as tf import tensorflow.compat.v1 as tf
from tensorflow_privacy.privacy.dp_query import dp_query from tensorflow_privacy.privacy.dp_query import dp_query

View file

@ -19,7 +19,7 @@ from __future__ import division
from __future__ import print_function from __future__ import print_function
from absl.testing import parameterized from absl.testing import parameterized
import tensorflow as tf import tensorflow.compat.v1 as tf
from tensorflow_privacy.privacy.dp_query import no_privacy_query from tensorflow_privacy.privacy.dp_query import no_privacy_query
from tensorflow_privacy.privacy.dp_query import test_utils from tensorflow_privacy.privacy.dp_query import test_utils

View file

@ -21,7 +21,7 @@ from __future__ import print_function
import collections import collections
import tensorflow as tf import tensorflow.compat.v1 as tf
from tensorflow_privacy.privacy.dp_query import dp_query from tensorflow_privacy.privacy.dp_query import dp_query

View file

@ -18,7 +18,7 @@ from __future__ import absolute_import
from __future__ import division from __future__ import division
from __future__ import print_function from __future__ import print_function
import tensorflow 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
from tensorflow_privacy.privacy.dp_query import normalized_query from tensorflow_privacy.privacy.dp_query import normalized_query

View file

@ -27,7 +27,7 @@ from __future__ import print_function
import collections import collections
import tensorflow as tf import tensorflow.compat.v1 as tf
from tensorflow_privacy.privacy.dp_query import dp_query from tensorflow_privacy.privacy.dp_query import dp_query
from tensorflow_privacy.privacy.dp_query import gaussian_query from tensorflow_privacy.privacy.dp_query import gaussian_query

View file

@ -21,7 +21,7 @@ from __future__ import print_function
from absl.testing import parameterized from absl.testing import parameterized
import numpy as np import numpy as np
import tensorflow as tf import tensorflow.compat.v1 as tf
from tensorflow_privacy.privacy.analysis import privacy_ledger from tensorflow_privacy.privacy.analysis import privacy_ledger
from tensorflow_privacy.privacy.dp_query import quantile_adaptive_clip_sum_query from tensorflow_privacy.privacy.dp_query import quantile_adaptive_clip_sum_query

View file

@ -19,7 +19,7 @@ from __future__ import print_function
from absl import logging from absl import logging
import tensorflow as tf import tensorflow.compat.v1 as tf
from tensorflow_privacy.privacy.analysis import privacy_ledger from tensorflow_privacy.privacy.analysis import privacy_ledger
from tensorflow_privacy.privacy.dp_query import gaussian_query from tensorflow_privacy.privacy.dp_query import gaussian_query

View file

@ -19,7 +19,7 @@ from __future__ import print_function
from absl.testing import parameterized from absl.testing import parameterized
import numpy as np import numpy as np
import tensorflow as tf import tensorflow.compat.v1 as tf
from tensorflow_privacy.privacy.analysis import privacy_ledger from tensorflow_privacy.privacy.analysis import privacy_ledger
from tensorflow_privacy.privacy.dp_query import gaussian_query from tensorflow_privacy.privacy.dp_query import gaussian_query

View file

@ -20,7 +20,7 @@ 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
import tensorflow as tf import tensorflow.compat.v1 as tf
from tensorflow_privacy.privacy.analysis import privacy_ledger from tensorflow_privacy.privacy.analysis import privacy_ledger
from tensorflow_privacy.privacy.dp_query import gaussian_query from tensorflow_privacy.privacy.dp_query import gaussian_query

View file

@ -19,7 +19,7 @@ from __future__ import print_function
from absl import logging from absl import logging
import tensorflow as tf import tensorflow.compat.v1 as tf
AdagradOptimizer = tf.compat.v1.train.AdagradOptimizer AdagradOptimizer = tf.compat.v1.train.AdagradOptimizer
AdamOptimizer = tf.compat.v1.train.AdamOptimizer AdamOptimizer = tf.compat.v1.train.AdamOptimizer

View file

@ -20,7 +20,7 @@ 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
import tensorflow 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
from tensorflow_privacy.privacy.optimizers.dp_optimizer_vectorized import VectorizedDPAdagrad from tensorflow_privacy.privacy.optimizers.dp_optimizer_vectorized import VectorizedDPAdagrad

View file

@ -15,7 +15,7 @@
from __future__ import absolute_import from __future__ import absolute_import
from __future__ import division from __future__ import division
from __future__ import print_function from __future__ import print_function
import tensorflow as tf # pylint: disable=wrong-import-position 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 losses # pylint: disable=wrong-import-position
from tensorflow_privacy.privacy.bolt_on import models # pylint: disable=wrong-import-position from tensorflow_privacy.privacy.bolt_on import models # pylint: disable=wrong-import-position
from tensorflow_privacy.privacy.bolt_on.optimizers import BoltOn # pylint: disable=wrong-import-position from tensorflow_privacy.privacy.bolt_on.optimizers import BoltOn # pylint: disable=wrong-import-position

View file

@ -41,7 +41,7 @@ from absl import app
from absl import flags from absl import flags
import numpy as np import numpy as np
import tensorflow as tf import tensorflow.compat.v1 as tf
import tensorflow_datasets as tfds import tensorflow_datasets as tfds
from tensorflow_privacy.privacy.analysis import privacy_ledger from tensorflow_privacy.privacy.analysis import privacy_ledger

View file

@ -22,7 +22,7 @@ from absl import app
from absl import flags from absl import flags
import numpy as np import numpy as np
import tensorflow as tf import tensorflow.compat.v1 as tf
from tensorflow_privacy.privacy.analysis import privacy_ledger from tensorflow_privacy.privacy.analysis import privacy_ledger
from tensorflow_privacy.privacy.analysis.rdp_accountant import compute_rdp_from_ledger from tensorflow_privacy.privacy.analysis.rdp_accountant import compute_rdp_from_ledger

View file

@ -20,7 +20,7 @@ from absl import app
from absl import flags from absl import flags
import numpy as np import numpy as np
import tensorflow as tf import tensorflow.compat.v1 as tf
from tensorflow_privacy.privacy.analysis.rdp_accountant import compute_rdp from tensorflow_privacy.privacy.analysis.rdp_accountant import compute_rdp
from tensorflow_privacy.privacy.analysis.rdp_accountant import get_privacy_spent from tensorflow_privacy.privacy.analysis.rdp_accountant import get_privacy_spent

View file

@ -22,7 +22,7 @@ from absl import flags
from absl import logging from absl import logging
import numpy as np import numpy as np
import tensorflow as tf import tensorflow.compat.v1 as tf
from tensorflow_privacy.privacy.analysis.rdp_accountant import compute_rdp from tensorflow_privacy.privacy.analysis.rdp_accountant import compute_rdp
from tensorflow_privacy.privacy.analysis.rdp_accountant import get_privacy_spent from tensorflow_privacy.privacy.analysis.rdp_accountant import get_privacy_spent

View file

@ -22,7 +22,7 @@ from absl import app
from absl import flags from absl import flags
import numpy as np import numpy as np
import tensorflow as tf import tensorflow.compat.v1 as tf
from tensorflow_privacy.privacy.analysis.rdp_accountant import compute_rdp from tensorflow_privacy.privacy.analysis.rdp_accountant import compute_rdp
from tensorflow_privacy.privacy.analysis.rdp_accountant import get_privacy_spent from tensorflow_privacy.privacy.analysis.rdp_accountant import get_privacy_spent