diff --git a/tensor2tensor/bin/build_vocab.py b/tensor2tensor/bin/build_vocab.py index b93ec94c2..efa172f1b 100644 --- a/tensor2tensor/bin/build_vocab.py +++ b/tensor2tensor/bin/build_vocab.py @@ -30,7 +30,7 @@ from tensor2tensor import problems as problems_lib # pylint: disable=unused-import from tensor2tensor.data_generators import text_problems from tensor2tensor.utils import registry -import tensorflow as tf +import tensorflow.compat.v1 as tf flags = tf.flags FLAGS = flags.FLAGS diff --git a/tensor2tensor/bin/make_tf_configs.py b/tensor2tensor/bin/make_tf_configs.py index ef847bc3e..ca7157032 100644 --- a/tensor2tensor/bin/make_tf_configs.py +++ b/tensor2tensor/bin/make_tf_configs.py @@ -30,7 +30,7 @@ from __future__ import print_function import json -import tensorflow as tf +import tensorflow.compat.v1 as tf flags = tf.flags FLAGS = flags.FLAGS diff --git a/tensor2tensor/bin/t2t-avg-all b/tensor2tensor/bin/t2t-avg-all index 696a20b5b..ecc6ddc09 100755 --- a/tensor2tensor/bin/t2t-avg-all +++ b/tensor2tensor/bin/t2t-avg-all @@ -6,7 +6,7 @@ from __future__ import print_function from tensor2tensor.bin import t2t_avg_all -import tensorflow as tf +import tensorflow.compat.v1 as tf def main(argv): t2t_avg_all.main(argv) diff --git a/tensor2tensor/bin/t2t-bleu b/tensor2tensor/bin/t2t-bleu index 6c51e480b..18214c07e 100755 --- a/tensor2tensor/bin/t2t-bleu +++ b/tensor2tensor/bin/t2t-bleu @@ -6,7 +6,7 @@ from __future__ import print_function from tensor2tensor.bin import t2t_bleu -import tensorflow as tf +import tensorflow.compat.v1 as tf def main(argv): t2t_bleu.main(argv) diff --git a/tensor2tensor/bin/t2t-datagen b/tensor2tensor/bin/t2t-datagen index a49ed5615..2150027af 100755 --- a/tensor2tensor/bin/t2t-datagen +++ b/tensor2tensor/bin/t2t-datagen @@ -17,7 +17,7 @@ from __future__ import print_function from tensor2tensor.bin import t2t_datagen -import tensorflow as tf +import tensorflow.compat.v1 as tf def main(argv): t2t_datagen.main(argv) diff --git a/tensor2tensor/bin/t2t-decoder b/tensor2tensor/bin/t2t-decoder index 9bcca1e9b..290b19fce 100755 --- a/tensor2tensor/bin/t2t-decoder +++ b/tensor2tensor/bin/t2t-decoder @@ -6,7 +6,7 @@ from __future__ import print_function from tensor2tensor.bin import t2t_decoder -import tensorflow as tf +import tensorflow.compat.v1 as tf def main(argv): t2t_decoder.main(argv) diff --git a/tensor2tensor/bin/t2t-exporter b/tensor2tensor/bin/t2t-exporter index 3166b0ee3..4ae638318 100755 --- a/tensor2tensor/bin/t2t-exporter +++ b/tensor2tensor/bin/t2t-exporter @@ -6,7 +6,7 @@ from __future__ import print_function from tensor2tensor.serving import export -import tensorflow as tf +import tensorflow.compat.v1 as tf def main(argv): export.main(argv) diff --git a/tensor2tensor/bin/t2t-insights-server b/tensor2tensor/bin/t2t-insights-server index e757b783c..799a8fe34 100755 --- a/tensor2tensor/bin/t2t-insights-server +++ b/tensor2tensor/bin/t2t-insights-server @@ -6,7 +6,7 @@ from __future__ import print_function from tensor2tensor.insights import server -import tensorflow as tf +import tensorflow.compat.v1 as tf def main(argv): server.main(argv) diff --git a/tensor2tensor/bin/t2t-make-tf-configs b/tensor2tensor/bin/t2t-make-tf-configs index 7142e9673..167dbcedb 100755 --- a/tensor2tensor/bin/t2t-make-tf-configs +++ b/tensor2tensor/bin/t2t-make-tf-configs @@ -6,7 +6,7 @@ from __future__ import print_function from tensor2tensor.bin import make_tf_configs -import tensorflow as tf +import tensorflow.compat.v1 as tf def main(argv): make_tf_configs.main(argv) diff --git a/tensor2tensor/bin/t2t-query-server b/tensor2tensor/bin/t2t-query-server index a354819db..82ea0d430 100755 --- a/tensor2tensor/bin/t2t-query-server +++ b/tensor2tensor/bin/t2t-query-server @@ -6,7 +6,7 @@ from __future__ import print_function from tensor2tensor.serving import query -import tensorflow as tf +import tensorflow.compat.v1 as tf def main(argv): query.main(argv) diff --git a/tensor2tensor/bin/t2t-trainer b/tensor2tensor/bin/t2t-trainer index c2f129409..0d713069d 100755 --- a/tensor2tensor/bin/t2t-trainer +++ b/tensor2tensor/bin/t2t-trainer @@ -22,7 +22,7 @@ from __future__ import print_function from tensor2tensor.bin import t2t_trainer -import tensorflow as tf +import tensorflow.compat.v1 as tf def main(argv): t2t_trainer.main(argv) diff --git a/tensor2tensor/bin/t2t-translate-all b/tensor2tensor/bin/t2t-translate-all index 9e8ee219b..4a6e67bf2 100755 --- a/tensor2tensor/bin/t2t-translate-all +++ b/tensor2tensor/bin/t2t-translate-all @@ -6,7 +6,7 @@ from __future__ import print_function from tensor2tensor.bin import t2t_translate_all -import tensorflow as tf +import tensorflow.compat.v1 as tf def main(argv): t2t_translate_all.main(argv) diff --git a/tensor2tensor/bin/t2t_attack.py b/tensor2tensor/bin/t2t_attack.py index b9e167238..11cc975a6 100644 --- a/tensor2tensor/bin/t2t_attack.py +++ b/tensor2tensor/bin/t2t_attack.py @@ -48,7 +48,7 @@ from tensor2tensor.utils import trainer_lib from tensor2tensor.utils import usr_dir -import tensorflow as tf +import tensorflow.compat.v1 as tf flags = tf.flags FLAGS = flags.FLAGS diff --git a/tensor2tensor/bin/t2t_avg_all.py b/tensor2tensor/bin/t2t_avg_all.py index 3755dc2d0..b616edb21 100644 --- a/tensor2tensor/bin/t2t_avg_all.py +++ b/tensor2tensor/bin/t2t_avg_all.py @@ -25,7 +25,7 @@ import six from six.moves import zip # pylint: disable=redefined-builtin from tensor2tensor.utils import bleu_hook -import tensorflow as tf +import tensorflow.compat.v1 as tf flags = tf.flags FLAGS = flags.FLAGS diff --git a/tensor2tensor/bin/t2t_bleu.py b/tensor2tensor/bin/t2t_bleu.py index ab4a5f014..f36df7450 100644 --- a/tensor2tensor/bin/t2t_bleu.py +++ b/tensor2tensor/bin/t2t_bleu.py @@ -59,7 +59,7 @@ import os import time from tensor2tensor.utils import bleu_hook -import tensorflow as tf +import tensorflow.compat.v1 as tf flags = tf.flags diff --git a/tensor2tensor/bin/t2t_datagen.py b/tensor2tensor/bin/t2t_datagen.py index b778bc984..9707f6a4f 100644 --- a/tensor2tensor/bin/t2t_datagen.py +++ b/tensor2tensor/bin/t2t_datagen.py @@ -52,7 +52,7 @@ pass # Improrting here to prevent pylint from ungrouped-imports warning. -import tensorflow as tf # pylint: disable=g-import-not-at-top +import tensorflow.compat.v1 as tf # pylint: disable=g-import-not-at-top flags = tf.flags diff --git a/tensor2tensor/bin/t2t_decoder.py b/tensor2tensor/bin/t2t_decoder.py index 84644b3c4..44abffd02 100644 --- a/tensor2tensor/bin/t2t_decoder.py +++ b/tensor2tensor/bin/t2t_decoder.py @@ -41,7 +41,7 @@ from tensor2tensor.utils import trainer_lib from tensor2tensor.utils import usr_dir -import tensorflow as tf +import tensorflow.compat.v1 as tf flags = tf.flags FLAGS = flags.FLAGS diff --git a/tensor2tensor/bin/t2t_distill.py b/tensor2tensor/bin/t2t_distill.py index f970a56c2..84ab5c577 100644 --- a/tensor2tensor/bin/t2t_distill.py +++ b/tensor2tensor/bin/t2t_distill.py @@ -31,7 +31,7 @@ from tensor2tensor.utils import trainer_lib from tensor2tensor.utils import usr_dir -import tensorflow as tf +import tensorflow.compat.v1 as tf flags = tf.flags FLAGS = flags.FLAGS diff --git a/tensor2tensor/bin/t2t_prune.py b/tensor2tensor/bin/t2t_prune.py index 008462e63..ece656d36 100644 --- a/tensor2tensor/bin/t2t_prune.py +++ b/tensor2tensor/bin/t2t_prune.py @@ -39,7 +39,7 @@ from tensor2tensor.utils import trainer_lib from tensor2tensor.utils import usr_dir -import tensorflow as tf +import tensorflow.compat.v1 as tf flags = tf.flags FLAGS = flags.FLAGS diff --git a/tensor2tensor/bin/t2t_trainer.py b/tensor2tensor/bin/t2t_trainer.py index fe9c8ac03..3c88d587a 100644 --- a/tensor2tensor/bin/t2t_trainer.py +++ b/tensor2tensor/bin/t2t_trainer.py @@ -32,7 +32,7 @@ from tensor2tensor.utils import registry from tensor2tensor.utils import trainer_lib from tensor2tensor.utils import usr_dir -import tensorflow as tf +import tensorflow.compat.v1 as tf from tensorflow.contrib.tpu.python.tpu import tpu_config diff --git a/tensor2tensor/bin/t2t_trainer_test.py b/tensor2tensor/bin/t2t_trainer_test.py index 63c206ab0..0140a47ec 100644 --- a/tensor2tensor/bin/t2t_trainer_test.py +++ b/tensor2tensor/bin/t2t_trainer_test.py @@ -21,7 +21,7 @@ from tensor2tensor.bin import t2t_trainer from tensor2tensor.utils import trainer_lib_test -import tensorflow as tf +import tensorflow.compat.v1 as tf FLAGS = tf.flags.FLAGS diff --git a/tensor2tensor/bin/t2t_translate_all.py b/tensor2tensor/bin/t2t_translate_all.py index 2d12e8246..ff6d42928 100644 --- a/tensor2tensor/bin/t2t_translate_all.py +++ b/tensor2tensor/bin/t2t_translate_all.py @@ -32,7 +32,7 @@ import shutil from tensor2tensor.utils import bleu_hook -import tensorflow as tf +import tensorflow.compat.v1 as tf flags = tf.flags FLAGS = flags.FLAGS diff --git a/tensor2tensor/layers/common_audio.py b/tensor2tensor/layers/common_audio.py index 14432576f..f72760923 100644 --- a/tensor2tensor/layers/common_audio.py +++ b/tensor2tensor/layers/common_audio.py @@ -22,7 +22,7 @@ import functools import numpy as np import scipy.signal -import tensorflow as tf +import tensorflow.compat.v1 as tf def add_delta_deltas(filterbanks, name=None): @@ -56,7 +56,7 @@ def compute_mel_filterbank_features( waveforms, sample_rate=16000, dither=1.0 / np.iinfo(np.int16).max, preemphasis=0.97, frame_length=25, frame_step=10, fft_length=None, - window_fn=functools.partial(tf.contrib.signal.hann_window, periodic=True), + window_fn=functools.partial(tf.signal.hann_window, periodic=True), lower_edge_hertz=80.0, upper_edge_hertz=7600.0, num_mel_bins=80, log_noise_floor=1e-3, apply_mask=True): """Implement mel-filterbank extraction using tf ops. diff --git a/tensor2tensor/layers/common_video.py b/tensor2tensor/layers/common_video.py index 646a50ec5..31a6c427d 100644 --- a/tensor2tensor/layers/common_video.py +++ b/tensor2tensor/layers/common_video.py @@ -22,12 +22,12 @@ import numpy as np from tensor2tensor.layers import common_layers -import tensorflow as tf +import tensorflow.compat.v1 as tf from tensorflow.python.ops import summary_op_util tfl = tf.layers -tfcl = tf.contrib.layers +tfcl = tf.layers def swap_time_and_batch_axes(inputs): @@ -60,7 +60,7 @@ def decode_to_shape(inputs, shape, scope): def basic_lstm(inputs, state, num_units, name=None): """Basic LSTM.""" input_shape = common_layers.shape_list(inputs) - cell = tf.contrib.rnn.BasicLSTMCell(num_units, name=name) + cell = tf.rnn.BasicLSTMCell(num_units, name=name) if state is None: state = cell.zero_state(input_shape[0], tf.float32) outputs, new_state = cell(inputs, state) @@ -80,7 +80,7 @@ def lstm_cell(inputs, name=None): """Full LSTM cell.""" input_shape = common_layers.shape_list(inputs) - cell = tf.contrib.rnn.LSTMCell(num_units, + cell = tf.rnn.LSTMCell(num_units, use_peepholes=use_peepholes, cell_clip=cell_clip, initializer=initializer, @@ -106,7 +106,7 @@ def conv_lstm_2d(inputs, state, output_channels, else: input_shape = spatial_dims + [input_channels] - cell = tf.contrib.rnn.ConvLSTMCell( + cell = tf.rnn.ConvLSTMCell( 2, input_shape, output_channels, [kernel_size, kernel_size], name=name) if state is None: diff --git a/tensor2tensor/utils/expert_utils.py b/tensor2tensor/utils/expert_utils.py index 01a525ded..d077df70e 100644 --- a/tensor2tensor/utils/expert_utils.py +++ b/tensor2tensor/utils/expert_utils.py @@ -32,7 +32,7 @@ from tensor2tensor.layers import common_layers from tensor2tensor.layers.vq_discrete import DiscreteBottleneck -import tensorflow as tf +import tensorflow.compat.v1 as tf DEFAULT_DEV_STRING = "existing_device" diff --git a/tensor2tensor/utils/metrics.py b/tensor2tensor/utils/metrics.py index d3fe98b64..e8d0d089a 100644 --- a/tensor2tensor/utils/metrics.py +++ b/tensor2tensor/utils/metrics.py @@ -26,9 +26,9 @@ from tensor2tensor.utils import bleu_hook from tensor2tensor.utils import rouge -import tensorflow as tf +import tensorflow.compat.v1 as tf -from tensorflow.contrib.eager.python import tfe +from tensorflow.compat.v1.eager.python import tfe class Metrics(object):