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

Substitute tensforflow import with tensorflow.compat.v1 #1872

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion tensor2tensor/bin/build_vocab.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion tensor2tensor/bin/make_tf_configs.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion tensor2tensor/bin/t2t-avg-all
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion tensor2tensor/bin/t2t-bleu
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion tensor2tensor/bin/t2t-datagen
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion tensor2tensor/bin/t2t-decoder
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion tensor2tensor/bin/t2t-exporter
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion tensor2tensor/bin/t2t-insights-server
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion tensor2tensor/bin/t2t-make-tf-configs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion tensor2tensor/bin/t2t-query-server
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion tensor2tensor/bin/t2t-trainer
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion tensor2tensor/bin/t2t-translate-all
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion tensor2tensor/bin/t2t_attack.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion tensor2tensor/bin/t2t_avg_all.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion tensor2tensor/bin/t2t_bleu.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion tensor2tensor/bin/t2t_datagen.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion tensor2tensor/bin/t2t_decoder.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion tensor2tensor/bin/t2t_distill.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion tensor2tensor/bin/t2t_prune.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion tensor2tensor/bin/t2t_trainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion tensor2tensor/bin/t2t_trainer_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion tensor2tensor/bin/t2t_translate_all.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions tensor2tensor/layers/common_audio.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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.
Expand Down
10 changes: 5 additions & 5 deletions tensor2tensor/layers/common_video.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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)
Expand All @@ -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,
Expand All @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion tensor2tensor/utils/expert_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
4 changes: 2 additions & 2 deletions tensor2tensor/utils/metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down