Skip to content
This repository was archived by the owner on Jul 7, 2023. It is now read-only.

Commit e908bcf

Browse files
afrozenatorcopybara-github
authored andcommitted
In files where we explicitly import tf.compat.v1, don't qualify access of tf.compat.v1 again.
PiperOrigin-RevId: 289135863
1 parent 8b0e689 commit e908bcf

14 files changed

+20
-21
lines changed

tensor2tensor/data_generators/generator_utils.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -867,18 +867,18 @@ def dict_pack(example):
867867

868868
def _standardize(self, dataset, keys):
869869
"""Force dataset structure into a tuple of Tensors."""
870-
shapes = tf.compat.v1.data.get_output_shapes(dataset)
870+
shapes = tf.data.get_output_shapes(dataset)
871871

872872
if isinstance(shapes, dict):
873873
keys = keys or tuple(shapes.keys())
874874
dataset = dataset.map(lambda x: tuple(x[k] for k in keys))
875-
shapes = tf.compat.v1.data.get_output_shapes(dataset)
875+
shapes = tf.data.get_output_shapes(dataset)
876876

877877
if not all(isinstance(i, tf.TensorShape) for i in shapes):
878878
# Internally this class expects tuples of Tensors, even for the degenerate
879879
# case of a single sequence.
880880
dataset = dataset.map(lambda x: (x,))
881-
shapes = tf.compat.v1.data.get_output_shapes(dataset)
881+
shapes = tf.data.get_output_shapes(dataset)
882882

883883
for s in shapes:
884884
if not s.is_compatible_with(tf.TensorShape([None])):
@@ -890,7 +890,7 @@ def _standardize(self, dataset, keys):
890890
if self._chop_long_sequences and len(shapes) != 1:
891891
raise ValueError("chop_long_sequences expects a single sequence dataset.")
892892

893-
token_types = tf.compat.v1.data.get_output_types(dataset)
893+
token_types = tf.data.get_output_types(dataset)
894894
if len(set(token_types)) > 1:
895895
raise ValueError("Inconsistent dtypes: {}".format(token_types))
896896

tensor2tensor/data_generators/problem_test.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
from tensor2tensor.utils import test_utils
3131

3232
import tensorflow.compat.v1 as tf
33-
tf.compat.v1.enable_eager_execution()
33+
tf.enable_eager_execution()
3434

3535

3636
def assert_tensors_equal(sess, t1, t2, n):

tensor2tensor/layers/common_video_test.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
from tensor2tensor.utils import test_utils
2727

2828
import tensorflow.compat.v1 as tf
29-
tf.compat.v1.enable_eager_execution()
29+
tf.enable_eager_execution()
3030

3131

3232
class CommonVideoTest(parameterized.TestCase, tf.test.TestCase):

tensor2tensor/layers/discretization_test.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
from tensor2tensor.utils import test_utils
2525

2626
import tensorflow.compat.v1 as tf
27-
tf.compat.v1.enable_eager_execution()
27+
tf.enable_eager_execution()
2828

2929

3030
class DiscretizationTest(tf.test.TestCase):

tensor2tensor/layers/latent_layers_test.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
from tensor2tensor.utils import test_utils
2929

3030
import tensorflow.compat.v1 as tf
31-
tf.compat.v1.enable_eager_execution()
31+
tf.enable_eager_execution()
3232

3333

3434
def imagetransformer_latent_tiny():

tensor2tensor/layers/modalities_test.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
from tensor2tensor.utils import test_utils
2727

2828
import tensorflow.compat.v1 as tf
29-
tf.compat.v1.enable_eager_execution()
29+
tf.enable_eager_execution()
3030

3131

3232
class ModalityTest(tf.test.TestCase):

tensor2tensor/layers/ngram_test.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
from tensor2tensor.utils import test_utils
2525

2626
import tensorflow.compat.v1 as tf
27-
tf.compat.v1.enable_eager_execution()
27+
tf.enable_eager_execution()
2828

2929

3030
class NGramTest(tf.test.TestCase):

tensor2tensor/utils/adafactor.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
import tensorflow.compat.v1 as tf
2525

2626

27-
class AdafactorOptimizer(tf.compat.v1.train.Optimizer):
27+
class AdafactorOptimizer(tf.train.Optimizer):
2828
"""Optimizer that implements the Adafactor algorithm.
2929
3030
Adafactor is described in https://arxiv.org/abs/1804.04235.

tensor2tensor/utils/multistep_optimizer.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
import tensorflow.compat.v1 as tf
3030

3131

32-
class MultistepAdamOptimizer(tf.compat.v1.train.AdamOptimizer):
32+
class MultistepAdamOptimizer(tf.train.AdamOptimizer):
3333
"""Adam with SGD updates every n steps with accumulated gradients."""
3434

3535
def __init__(self, learning_rate=0.001, beta1=0.9, beta2=0.999, epsilon=1e-8,

tensor2tensor/utils/optimize.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ def _register_base_optimizer(name, opt):
184184
_register_base_optimizer(_name, _opt)
185185

186186

187-
class ConditionalOptimizer(tf.compat.v1.train.Optimizer):
187+
class ConditionalOptimizer(tf.train.Optimizer):
188188
"""Conditional optimizer."""
189189

190190
def __init__(self, optimizer_name, lr, hparams, use_tpu=False): # pylint: disable=super-init-not-called

tensor2tensor/utils/t2t_model_test.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
from tensor2tensor.utils import test_utils
2626

2727
import tensorflow.compat.v1 as tf
28-
tf.compat.v1.enable_eager_execution()
28+
tf.enable_eager_execution()
2929

3030

3131
class T2TModelTest(tf.test.TestCase):

tensor2tensor/utils/test_utils.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def run_in_graph_and_eager_modes(func=None,
3939
For example, consider the following unittest:
4040
4141
```python
42-
tf.compat.v1.enable_eager_execution()
42+
tf.enable_eager_execution()
4343
4444
class SomeTest(tf.test.TestCase):
4545
@@ -120,5 +120,5 @@ def decorated(self, *args, **kwargs):
120120

121121

122122
def test_main():
123-
tf.compat.v1.enable_eager_execution()
123+
tf.enable_eager_execution()
124124
tf.test.main()

tensor2tensor/utils/test_utils_test.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@
2222
from tensor2tensor.utils import test_utils
2323

2424
import tensorflow.compat.v1 as tf
25-
26-
tf.compat.v1.enable_eager_execution()
25+
tf.enable_eager_execution()
2726

2827

2928
class RunInGraphAndEagerTest(tf.test.TestCase):

tensor2tensor/utils/yellowfin.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@
2222

2323

2424
# Values for gate_gradients.
25-
GATE_NONE = tf.compat.v1.train.Optimizer.GATE_NONE
26-
GATE_OP = tf.compat.v1.train.Optimizer.GATE_OP
27-
GATE_GRAPH = tf.compat.v1.train.Optimizer.GATE_GRAPH
25+
GATE_NONE = tf.train.Optimizer.GATE_NONE
26+
GATE_OP = tf.train.Optimizer.GATE_OP
27+
GATE_GRAPH = tf.train.Optimizer.GATE_GRAPH
2828

2929

3030
class YellowFinOptimizer(object):

0 commit comments

Comments
 (0)