Skip to content

Commit

Permalink
Explicitly replace "import tensorflow" with "tensorflow.compat.v1"
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 289911906
  • Loading branch information
sun51 authored and copybara-github committed Jan 15, 2020
1 parent 24a14a5 commit a351cd1
Show file tree
Hide file tree
Showing 23 changed files with 26 additions and 26 deletions.
4 changes: 2 additions & 2 deletions cnn_quantization/tf_cnn_benchmarks/benchmark_cnn_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -702,7 +702,7 @@ def testMoveTrainDir(self):
params = params._replace(train_dir=new_train_dir, eval=True)
self._run_benchmark_cnn_with_black_and_white_images(params)

@mock.patch('tensorflow.train.Saver')
@mock.patch.object(tf.train, 'Saver')
@mock.patch('benchmark_cnn._get_checkpoint_to_load') # pylint: disable=line-too-long
def testLoadCheckpoint(self, mock_checkpoint_to_load, mock_saver):
"""Tests load checkpoint with full path to checkpoint."""
Expand All @@ -726,7 +726,7 @@ def testGetCheckpointToLoadException(self):
self.assertRaises(benchmark_cnn.CheckpointNotFoundException,
benchmark_cnn._get_checkpoint_to_load, ckpt_path)

@mock.patch('tensorflow.train.get_checkpoint_state')
@mock.patch.object(tf.train, 'get_checkpoint_state')
def testGetCheckpointToLoad(self, mock_checkpoint_state):
"""Tests passing path to checkpoint folder."""
expected_checkpoint = '/path/to/checkpoints/model.ckpt-1243'
Expand Down
2 changes: 1 addition & 1 deletion correct_batch_effects_wdn/distance_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import numpy as np
import pandas as pd
import pandas.util.testing as pandas_testing
import tensorflow as tf
import tensorflow.compat.v1 as tf

from correct_batch_effects_wdn import distance

Expand Down
2 changes: 1 addition & 1 deletion correct_batch_effects_wdn/evaluate_metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
from sklearn import ensemble
from sklearn import metrics
import sklearn.linear_model as lm
from tensorflow import gfile
from tensorflow.compat.v1 import gfile

from correct_batch_effects_wdn import distance as distance_analysis
from correct_batch_effects_wdn import evaluate
Expand Down
2 changes: 1 addition & 1 deletion correct_batch_effects_wdn/evaluate_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import numpy.testing as numpy_testing
import pandas as pd
from six.moves import range
import tensorflow as tf
import tensorflow.compat.v1 as tf

from correct_batch_effects_wdn import evaluate
from correct_batch_effects_wdn import metadata
Expand Down
4 changes: 2 additions & 2 deletions correct_batch_effects_wdn/forgetting_nuisance.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@
from six.moves import range
from six.moves import zip
import six.moves.cPickle as pickle
import tensorflow as tf
from tensorflow import gfile
import tensorflow.compat.v1 as tf
from tensorflow.compat.v1 import gfile

from correct_batch_effects_wdn import io_utils
from correct_batch_effects_wdn import transform
Expand Down
2 changes: 1 addition & 1 deletion correct_batch_effects_wdn/forgetting_nuisance_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import numpy as np
from numpy import linalg as la
import pandas as pd
import tensorflow as tf
import tensorflow.compat.v1 as tf

from correct_batch_effects_wdn import forgetting_nuisance

Expand Down
2 changes: 1 addition & 1 deletion correct_batch_effects_wdn/io_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
from __future__ import print_function

import pandas
from tensorflow import gfile
from tensorflow.compat.v1 import gfile


def write_dataframe_to_hdf5(df, path, complib='zlib', complevel=5, key='data'):
Expand Down
2 changes: 1 addition & 1 deletion correct_batch_effects_wdn/io_utils_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
from absl import flags

import pandas
import tensorflow as tf
import tensorflow.compat.v1 as tf

from correct_batch_effects_wdn import io_utils

Expand Down
2 changes: 1 addition & 1 deletion correct_batch_effects_wdn/ljosa_embeddings_to_h5.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
import numpy as np
import pandas
from six.moves import range
from tensorflow import gfile
from tensorflow.compat.v1 import gfile

from correct_batch_effects_wdn import io_utils

Expand Down
2 changes: 1 addition & 1 deletion correct_batch_effects_wdn/transform.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import numpy as np
import pandas as pd
from sklearn import decomposition
import tensorflow as tf
import tensorflow.compat.v1 as tf

from correct_batch_effects_wdn import metadata

Expand Down
2 changes: 1 addition & 1 deletion correct_batch_effects_wdn/transform_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import pandas as pd
import pandas.util.testing as pandas_testing
from six.moves import range
import tensorflow as tf
import tensorflow.compat.v1 as tf

from correct_batch_effects_wdn import metadata
from correct_batch_effects_wdn import transform
Expand Down
2 changes: 1 addition & 1 deletion simulation_research/tf_risk/controllers.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
from __future__ import print_function

import numpy as np
import tensorflow as tf
import tensorflow.compat.v1 as tf

from typing import Mapping, Union

Expand Down
2 changes: 1 addition & 1 deletion simulation_research/tf_risk/dynamics.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
from __future__ import print_function

import numpy as np
import tensorflow as tf
import tensorflow.compat.v1 as tf

from typing import Callable, List, Optional, Tuple, Union

Expand Down
4 changes: 2 additions & 2 deletions simulation_research/tf_risk/dynamics_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
from __future__ import print_function

import numpy as np
import tensorflow as tf # tf
import tensorflow.compat.v1 as tf # tf

from simulation_research.tf_risk import dynamics
from tensorflow.contrib import stateless as contrib_stateless
Expand Down Expand Up @@ -1079,7 +1079,7 @@ def test_gbm_log_euler_step_nd_output_changes_with_key(self):
# The step is a bijection w.r.t. dw_t, all terms should be different.
self.assertAllDistinct(next_log_states_0_eval, next_log_states_1_eval)

@tf.test.mock.patch('tensorflow.random.stateless_normal')
@tf.test.mock.patch.object(tf.random, 'stateless_normal')
def test_random_normal(self, mock_stateless_random_normal):
_ = dynamics.random_normal(shape=[3, 1], i=41 / 5, key=9)
_, call_args = mock_stateless_random_normal.call_args
Expand Down
2 changes: 1 addition & 1 deletion simulation_research/tf_risk/monte_carlo_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
from absl import logging

import numpy as np
import tensorflow as tf
import tensorflow.compat.v1 as tf

from typing import Callable, MutableMapping, List, Optional, Tuple, Union
from simulation_research.tf_risk import util
Expand Down
2 changes: 1 addition & 1 deletion simulation_research/tf_risk/monte_carlo_manager_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
from absl.testing import parameterized

import numpy as np
import tensorflow as tf # tf
import tensorflow.compat.v1 as tf # tf

from simulation_research.tf_risk import dynamics
from simulation_research.tf_risk import monte_carlo_manager
Expand Down
2 changes: 1 addition & 1 deletion simulation_research/tf_risk/payoffs.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
from __future__ import print_function

import numpy as np
import tensorflow as tf
import tensorflow.compat.v1 as tf

from typing import Tuple, Optional, Union

Expand Down
2 changes: 1 addition & 1 deletion simulation_research/tf_risk/payoffs_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
from __future__ import print_function

import numpy as np
import tensorflow as tf # tf
import tensorflow.compat.v1 as tf # tf

from simulation_research.tf_risk import payoffs

Expand Down
2 changes: 1 addition & 1 deletion simulation_research/tf_risk/risk_metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
from __future__ import print_function

import numpy as np
import tensorflow as tf
import tensorflow.compat.v1 as tf

from typing import List, MutableMapping, Optional, Tuple, Union

Expand Down
2 changes: 1 addition & 1 deletion simulation_research/tf_risk/risk_metrics_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

import numpy as np
import scipy.stats
import tensorflow as tf # tf
import tensorflow.compat.v1 as tf # tf

from simulation_research.tf_risk import dynamics
from simulation_research.tf_risk import monte_carlo_manager
Expand Down
2 changes: 1 addition & 1 deletion simulation_research/tf_risk/run_replication_experiment.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@

import numpy as np
import scipy.linalg
import tensorflow as tf
import tensorflow.compat.v1 as tf

from simulation_research.tf_risk import controllers
from simulation_research.tf_risk import monte_carlo_manager
Expand Down
2 changes: 1 addition & 1 deletion simulation_research/tf_risk/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

import numpy as np
import scipy.stats
import tensorflow as tf
import tensorflow.compat.v1 as tf

from typing import Union, TypeVar

Expand Down
2 changes: 1 addition & 1 deletion simulation_research/tf_risk/util_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
from __future__ import print_function

import numpy as np
import tensorflow as tf # tf
import tensorflow.compat.v1 as tf # tf

from simulation_research.tf_risk import util

Expand Down

0 comments on commit a351cd1

Please sign in to comment.