aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--tensorflow/contrib/distributions/python/ops/gamma.py2
-rw-r--r--tensorflow/contrib/distributions/python/ops/mvn.py2
-rw-r--r--tensorflow/contrib/distributions/python/ops/normal.py2
-rw-r--r--tensorflow/contrib/distributions/python/ops/student_t.py2
-rw-r--r--tensorflow/contrib/distributions/python/ops/uniform.py2
-rw-r--r--tensorflow/contrib/layers/python/layers/optimizers.py2
-rw-r--r--tensorflow/contrib/learn/python/learn/dataframe/transforms/csv_parser.py2
-rw-r--r--tensorflow/contrib/learn/python/learn/estimators/base.py2
-rw-r--r--tensorflow/contrib/learn/python/learn/io/graph_io.py2
-rw-r--r--tensorflow/contrib/metrics/python/ops/histogram_ops.py2
-rw-r--r--tensorflow/contrib/quantization/python/math_ops.py2
-rw-r--r--tensorflow/contrib/quantization/python/nn_ops.py2
-rw-r--r--tensorflow/contrib/quantization/tools/quantize_graph.py2
-rw-r--r--tensorflow/contrib/quantization/tools/quantize_graph_test.py2
-rw-r--r--tensorflow/contrib/slim/python/slim/learning.py2
-rw-r--r--tensorflow/examples/image_retraining/retrain.py2
-rw-r--r--tensorflow/python/BUILD19
-rw-r--r--tensorflow/python/__init__.py2
-rw-r--r--tensorflow/python/client/session_test.py2
-rw-r--r--tensorflow/python/framework/common_shapes.py (renamed from tensorflow/python/ops/common_shapes.py)0
-rw-r--r--tensorflow/python/framework/constant_op.py226
-rw-r--r--tensorflow/python/framework/gen_docs_combined.py48
-rw-r--r--tensorflow/python/framework/graph_util.py (renamed from tensorflow/python/client/graph_util.py)0
-rw-r--r--tensorflow/python/framework/graph_util_test.py (renamed from tensorflow/python/client/graph_util_test.py)4
-rw-r--r--tensorflow/python/framework/op_def_library.py (renamed from tensorflow/python/ops/op_def_library.py)1
-rw-r--r--tensorflow/python/framework/op_def_library_test.py (renamed from tensorflow/python/ops/op_def_library_test.py)85
-rw-r--r--tensorflow/python/framework/ops_test.py4
-rw-r--r--tensorflow/python/framework/python_op_gen.cc2
-rw-r--r--tensorflow/python/framework/test_util_test.py2
-rw-r--r--tensorflow/python/kernel_tests/gradient_checker.py2
-rw-r--r--tensorflow/python/kernel_tests/sparse_ops_test.py2
-rw-r--r--tensorflow/python/ops/array_grad.py2
-rw-r--r--tensorflow/python/ops/array_ops.py8
-rw-r--r--tensorflow/python/ops/clip_ops.py2
-rw-r--r--tensorflow/python/ops/control_flow_ops.py4
-rw-r--r--tensorflow/python/ops/data_flow_grad.py1
-rw-r--r--tensorflow/python/ops/data_flow_ops.py2
-rw-r--r--tensorflow/python/ops/embedding_ops.py2
-rw-r--r--tensorflow/python/ops/functional_ops.py2
-rw-r--r--tensorflow/python/ops/gradients.py2
-rw-r--r--tensorflow/python/ops/gradients_test.py4
-rw-r--r--tensorflow/python/ops/image_ops.py2
-rw-r--r--tensorflow/python/ops/image_ops_test.py4
-rw-r--r--tensorflow/python/ops/init_ops.py2
-rw-r--r--tensorflow/python/ops/io_ops.py2
-rw-r--r--tensorflow/python/ops/linalg_grad.py1
-rw-r--r--tensorflow/python/ops/logging_ops.py2
-rw-r--r--tensorflow/python/ops/math_grad.py2
-rw-r--r--tensorflow/python/ops/math_ops.py8
-rw-r--r--tensorflow/python/ops/math_ops_test.py2
-rw-r--r--tensorflow/python/ops/nn.py2
-rw-r--r--tensorflow/python/ops/nn_ops.py4
-rw-r--r--tensorflow/python/ops/parsing_ops.py4
-rw-r--r--tensorflow/python/ops/random_ops.py2
-rw-r--r--tensorflow/python/ops/script_ops.py2
-rw-r--r--tensorflow/python/ops/state_ops.py2
-rw-r--r--tensorflow/python/ops/string_ops.py2
-rw-r--r--tensorflow/python/ops/tensor_array_ops.py2
-rw-r--r--tensorflow/python/tools/freeze_graph.py2
-rw-r--r--tensorflow/python/tools/strip_unused.py2
-rw-r--r--tensorflow/python/training/adadelta.py1
-rw-r--r--tensorflow/python/training/adagrad.py2
-rw-r--r--tensorflow/python/training/ftrl.py2
-rw-r--r--tensorflow/python/training/gradient_descent.py1
-rw-r--r--tensorflow/python/training/input.py2
-rw-r--r--tensorflow/python/training/momentum.py1
-rw-r--r--tensorflow/python/training/proximal_adagrad.py2
-rw-r--r--tensorflow/python/training/rmsprop.py2
-rw-r--r--tensorflow/python/training/saver.py4
-rw-r--r--tensorflow/python/training/training_ops_test.py2
70 files changed, 383 insertions, 145 deletions
diff --git a/tensorflow/contrib/distributions/python/ops/gamma.py b/tensorflow/contrib/distributions/python/ops/gamma.py
index 621459e2d7..9593953448 100644
--- a/tensorflow/contrib/distributions/python/ops/gamma.py
+++ b/tensorflow/contrib/distributions/python/ops/gamma.py
@@ -22,12 +22,12 @@ import numpy as np
from tensorflow.contrib.distributions.python.ops import distribution # pylint: disable=line-too-long
from tensorflow.contrib.framework.python.framework import tensor_util as contrib_tensor_util # pylint: disable=line-too-long
+from tensorflow.python.framework import constant_op
from tensorflow.python.framework import dtypes
from tensorflow.python.framework import ops
from tensorflow.python.framework import tensor_shape
from tensorflow.python.ops import array_ops
from tensorflow.python.ops import check_ops
-from tensorflow.python.ops import constant_op
from tensorflow.python.ops import control_flow_ops
from tensorflow.python.ops import math_ops
from tensorflow.python.ops import random_ops
diff --git a/tensorflow/contrib/distributions/python/ops/mvn.py b/tensorflow/contrib/distributions/python/ops/mvn.py
index e696324624..2e5d93a0fb 100644
--- a/tensorflow/contrib/distributions/python/ops/mvn.py
+++ b/tensorflow/contrib/distributions/python/ops/mvn.py
@@ -21,11 +21,11 @@ from __future__ import print_function
import math
from tensorflow.contrib.framework.python.framework import tensor_util as contrib_tensor_util # pylint: disable=line-too-long
+from tensorflow.python.framework import constant_op
from tensorflow.python.framework import ops
from tensorflow.python.framework import tensor_shape
from tensorflow.python.framework import tensor_util
from tensorflow.python.ops import array_ops
-from tensorflow.python.ops import constant_op
from tensorflow.python.ops import control_flow_ops
from tensorflow.python.ops import linalg_ops
from tensorflow.python.ops import logging_ops
diff --git a/tensorflow/contrib/distributions/python/ops/normal.py b/tensorflow/contrib/distributions/python/ops/normal.py
index be493f1d86..bfa8e474c4 100644
--- a/tensorflow/contrib/distributions/python/ops/normal.py
+++ b/tensorflow/contrib/distributions/python/ops/normal.py
@@ -22,13 +22,13 @@ import math
from tensorflow.contrib.distributions.python.ops import distribution # pylint: disable=line-too-long
from tensorflow.contrib.framework.python.framework import tensor_util as contrib_tensor_util # pylint: disable=line-too-long
+from tensorflow.python.framework import constant_op
from tensorflow.python.framework import dtypes
from tensorflow.python.framework import ops
from tensorflow.python.framework import tensor_shape
from tensorflow.python.framework import tensor_util
from tensorflow.python.ops import array_ops
from tensorflow.python.ops import check_ops
-from tensorflow.python.ops import constant_op
from tensorflow.python.ops import math_ops
from tensorflow.python.ops import random_ops
diff --git a/tensorflow/contrib/distributions/python/ops/student_t.py b/tensorflow/contrib/distributions/python/ops/student_t.py
index 0b674fc7bd..03fb407597 100644
--- a/tensorflow/contrib/distributions/python/ops/student_t.py
+++ b/tensorflow/contrib/distributions/python/ops/student_t.py
@@ -24,12 +24,12 @@ import numpy as np
from tensorflow.contrib.distributions.python.ops import distribution # pylint: disable=line-too-long
from tensorflow.contrib.framework.python.framework import tensor_util as contrib_tensor_util # pylint: disable=line-too-long
+from tensorflow.python.framework import constant_op
from tensorflow.python.framework import ops
from tensorflow.python.framework import tensor_shape
from tensorflow.python.framework import tensor_util
from tensorflow.python.ops import array_ops
from tensorflow.python.ops import check_ops
-from tensorflow.python.ops import constant_op
from tensorflow.python.ops import math_ops
from tensorflow.python.ops import random_ops
from tensorflow.python.ops import special_math_ops
diff --git a/tensorflow/contrib/distributions/python/ops/uniform.py b/tensorflow/contrib/distributions/python/ops/uniform.py
index 383c6b6311..1a6cb8671e 100644
--- a/tensorflow/contrib/distributions/python/ops/uniform.py
+++ b/tensorflow/contrib/distributions/python/ops/uniform.py
@@ -21,12 +21,12 @@ from __future__ import print_function
from tensorflow.contrib.distributions.python.ops import distribution # pylint: disable=line-too-long
from tensorflow.contrib.framework.python.framework import tensor_util as contrib_tensor_util # pylint: disable=line-too-long
from tensorflow.python.framework import dtypes
+from tensorflow.python.framework import constant_op
from tensorflow.python.framework import ops
from tensorflow.python.framework import tensor_shape
from tensorflow.python.framework import tensor_util
from tensorflow.python.ops import array_ops
from tensorflow.python.ops import check_ops
-from tensorflow.python.ops import constant_op
from tensorflow.python.ops import math_ops
from tensorflow.python.ops import random_ops
diff --git a/tensorflow/contrib/layers/python/layers/optimizers.py b/tensorflow/contrib/layers/python/layers/optimizers.py
index 460eb959c6..cfee1ec142 100644
--- a/tensorflow/contrib/layers/python/layers/optimizers.py
+++ b/tensorflow/contrib/layers/python/layers/optimizers.py
@@ -20,11 +20,11 @@ from __future__ import print_function
import six
+from tensorflow.python.framework import constant_op
from tensorflow.python.framework import dtypes
from tensorflow.python.framework import ops
from tensorflow.python.ops import array_ops
from tensorflow.python.ops import clip_ops
-from tensorflow.python.ops import constant_op
from tensorflow.python.ops import control_flow_ops
from tensorflow.python.ops import init_ops
from tensorflow.python.ops import logging_ops
diff --git a/tensorflow/contrib/learn/python/learn/dataframe/transforms/csv_parser.py b/tensorflow/contrib/learn/python/learn/dataframe/transforms/csv_parser.py
index 5dcb4f3fd4..caa83f5a96 100644
--- a/tensorflow/contrib/learn/python/learn/dataframe/transforms/csv_parser.py
+++ b/tensorflow/contrib/learn/python/learn/dataframe/transforms/csv_parser.py
@@ -19,7 +19,7 @@ from __future__ import division
from __future__ import print_function
from tensorflow.contrib.learn.python.learn.dataframe import transform
-from tensorflow.python.ops import constant_op
+from tensorflow.python.framework import constant_op
from tensorflow.python.ops import parsing_ops
diff --git a/tensorflow/contrib/learn/python/learn/estimators/base.py b/tensorflow/contrib/learn/python/learn/estimators/base.py
index 3c41306ff7..d9ca75b7ca 100644
--- a/tensorflow/contrib/learn/python/learn/estimators/base.py
+++ b/tensorflow/contrib/learn/python/learn/estimators/base.py
@@ -35,8 +35,8 @@ from tensorflow.contrib.learn.python.learn.estimators import estimator
from tensorflow.contrib.learn.python.learn.estimators._sklearn import NotFittedError
from tensorflow.contrib.learn.python.learn.io.data_feeder import setup_train_data_feeder
+from tensorflow.python.framework import constant_op
from tensorflow.python.framework import ops
-from tensorflow.python.ops import constant_op
from tensorflow.python.platform import gfile
from tensorflow.python.platform import tf_logging as logging
diff --git a/tensorflow/contrib/learn/python/learn/io/graph_io.py b/tensorflow/contrib/learn/python/learn/io/graph_io.py
index f4db385349..207ed6fa1c 100644
--- a/tensorflow/contrib/learn/python/learn/io/graph_io.py
+++ b/tensorflow/contrib/learn/python/learn/io/graph_io.py
@@ -19,8 +19,8 @@ from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
+from tensorflow.python.framework import constant_op
from tensorflow.python.framework import ops
-from tensorflow.python.ops import constant_op
from tensorflow.python.ops import io_ops
from tensorflow.python.ops import parsing_ops
from tensorflow.python.platform import gfile
diff --git a/tensorflow/contrib/metrics/python/ops/histogram_ops.py b/tensorflow/contrib/metrics/python/ops/histogram_ops.py
index d6e0faf5b1..60c26149ea 100644
--- a/tensorflow/contrib/metrics/python/ops/histogram_ops.py
+++ b/tensorflow/contrib/metrics/python/ops/histogram_ops.py
@@ -23,10 +23,10 @@ from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
+from tensorflow.python.framework import constant_op
from tensorflow.python.framework import dtypes
from tensorflow.python.framework import ops
from tensorflow.python.ops import array_ops
-from tensorflow.python.ops import constant_op
from tensorflow.python.ops import control_flow_ops
from tensorflow.python.ops import histogram_ops
from tensorflow.python.ops import logging_ops
diff --git a/tensorflow/contrib/quantization/python/math_ops.py b/tensorflow/contrib/quantization/python/math_ops.py
index 2d9d6f4eea..43c1409358 100644
--- a/tensorflow/contrib/quantization/python/math_ops.py
+++ b/tensorflow/contrib/quantization/python/math_ops.py
@@ -21,9 +21,9 @@ from __future__ import print_function
# pylint: disable=unused-import,wildcard-import
from tensorflow.contrib.quantization.ops import gen_math_ops
from tensorflow.contrib.quantization.ops.gen_math_ops import *
+from tensorflow.python.framework import common_shapes
from tensorflow.python.framework import ops
from tensorflow.python.framework import tensor_shape
-from tensorflow.python.ops import common_shapes
# QuantizedMatMul* ops.
diff --git a/tensorflow/contrib/quantization/python/nn_ops.py b/tensorflow/contrib/quantization/python/nn_ops.py
index 91bc2c071f..33af3c1e2c 100644
--- a/tensorflow/contrib/quantization/python/nn_ops.py
+++ b/tensorflow/contrib/quantization/python/nn_ops.py
@@ -21,9 +21,9 @@ from __future__ import print_function
# pylint: disable=unused-import,wildcard-import
from tensorflow.contrib.quantization.ops import gen_nn_ops
from tensorflow.contrib.quantization.ops.gen_nn_ops import *
+from tensorflow.python.framework import common_shapes
from tensorflow.python.framework import ops
from tensorflow.python.framework import tensor_shape
-from tensorflow.python.ops import common_shapes
# QuantizedAvgPool* ops.
diff --git a/tensorflow/contrib/quantization/tools/quantize_graph.py b/tensorflow/contrib/quantization/tools/quantize_graph.py
index aafd3e0485..34bc61d06d 100644
--- a/tensorflow/contrib/quantization/tools/quantize_graph.py
+++ b/tensorflow/contrib/quantization/tools/quantize_graph.py
@@ -32,7 +32,7 @@ import re
import numpy as np
import tensorflow as tf
-from tensorflow.python.client import graph_util
+from tensorflow.python.framework import graph_util
from tensorflow.python.framework import tensor_util
# TODO(petewarden) - Remove this ugly hack to get around Python linking problems
diff --git a/tensorflow/contrib/quantization/tools/quantize_graph_test.py b/tensorflow/contrib/quantization/tools/quantize_graph_test.py
index cd3ecd383d..72c2b09346 100644
--- a/tensorflow/contrib/quantization/tools/quantize_graph_test.py
+++ b/tensorflow/contrib/quantization/tools/quantize_graph_test.py
@@ -24,7 +24,7 @@ import numpy as np
import tensorflow as tf
from tensorflow.contrib.quantization.tools import quantize_graph
-from tensorflow.python.client import graph_util
+from tensorflow.python.framework import graph_util
flags = tf.app.flags
FLAGS = flags.FLAGS
diff --git a/tensorflow/contrib/slim/python/slim/learning.py b/tensorflow/contrib/slim/python/slim/learning.py
index 4d1bf7daa8..e2e940da05 100644
--- a/tensorflow/contrib/slim/python/slim/learning.py
+++ b/tensorflow/contrib/slim/python/slim/learning.py
@@ -42,10 +42,10 @@ import sys
import time
from tensorflow.contrib.framework.python.ops import variables
+from tensorflow.python.framework import constant_op
from tensorflow.python.framework import ops
from tensorflow.python.ops import array_ops
from tensorflow.python.ops import clip_ops
-from tensorflow.python.ops import constant_op
from tensorflow.python.ops import control_flow_ops
from tensorflow.python.ops import logging_ops
from tensorflow.python.ops import math_ops
diff --git a/tensorflow/examples/image_retraining/retrain.py b/tensorflow/examples/image_retraining/retrain.py
index 484dd89545..9b01376577 100644
--- a/tensorflow/examples/image_retraining/retrain.py
+++ b/tensorflow/examples/image_retraining/retrain.py
@@ -67,7 +67,7 @@ import numpy as np
from six.moves import urllib
import tensorflow as tf
-from tensorflow.python.client import graph_util
+from tensorflow.python.framework import graph_util
from tensorflow.python.framework import tensor_shape
from tensorflow.python.platform import gfile
diff --git a/tensorflow/python/BUILD b/tensorflow/python/BUILD
index 938c0e1b12..8b8eb01f2b 100644
--- a/tensorflow/python/BUILD
+++ b/tensorflow/python/BUILD
@@ -184,17 +184,16 @@ cc_library(
py_library(
name = "framework_for_generated_wrappers",
srcs = [
+ "framework/constant_op.py",
"framework/device.py",
"framework/dtypes.py",
"framework/function.py",
+ "framework/op_def_library.py",
"framework/op_def_registry.py",
"framework/ops.py",
"framework/registry.py",
"framework/tensor_shape.py",
"framework/versions.py",
- # TODO(josh11b): Move this to the framework directory
- "ops/op_def_library.py",
- "ops/constant_op.py",
],
srcs_version = "PY2AND3",
visibility = ["//visibility:public"],
@@ -208,16 +207,14 @@ py_library(
py_library(
name = "framework",
srcs = [
- # TODO(mrry): Move this to the framework directory.
- "client/graph_util.py",
+ "framework/common_shapes.py",
"framework/errors.py",
"framework/framework_lib.py",
+ "framework/graph_util.py",
"framework/importer.py",
+ "framework/load_library.py",
"framework/random_seed.py",
"framework/tensor_util.py",
- "framework/load_library.py",
- # TODO(josh11b): Move this to the framework directory
- "ops/common_shapes.py",
],
srcs_version = "PY2AND3",
deps = [
@@ -466,8 +463,8 @@ py_test(
py_test(
name = "op_def_library_test",
size = "small",
- srcs = ["ops/op_def_library_test.py"],
- main = "ops/op_def_library_test.py",
+ srcs = ["framework/op_def_library_test.py"],
+ main = "framework/op_def_library_test.py",
srcs_version = "PY2AND3",
deps = [
":framework_test_lib",
@@ -1107,7 +1104,7 @@ py_test(
py_test(
name = "graph_util_test",
size = "small",
- srcs = ["client/graph_util_test.py"],
+ srcs = ["framework/graph_util_test.py"],
srcs_version = "PY2AND3",
deps = [
":framework",
diff --git a/tensorflow/python/__init__.py b/tensorflow/python/__init__.py
index f8eb29840b..3b51307a99 100644
--- a/tensorflow/python/__init__.py
+++ b/tensorflow/python/__init__.py
@@ -100,10 +100,10 @@ from tensorflow.python.util.all_util import make_all
# Import modules whose docstrings contribute, for use by make_all below.
from tensorflow.python.client import client_lib
+from tensorflow.python.framework import constant_op
from tensorflow.python.framework import framework_lib
from tensorflow.python.ops import array_ops
from tensorflow.python.ops import check_ops
-from tensorflow.python.ops import constant_op
from tensorflow.python.ops import control_flow_ops
from tensorflow.python.ops import functional_ops
from tensorflow.python.ops import histogram_ops
diff --git a/tensorflow/python/client/session_test.py b/tensorflow/python/client/session_test.py
index 00055d7d97..17819a5077 100644
--- a/tensorflow/python/client/session_test.py
+++ b/tensorflow/python/client/session_test.py
@@ -28,6 +28,7 @@ from six.moves import xrange # pylint: disable=redefined-builtin
from tensorflow.core.lib.core import error_codes_pb2
from tensorflow.core.protobuf import config_pb2
from tensorflow.python.client import session
+from tensorflow.python.framework import constant_op
from tensorflow.python.framework import dtypes
from tensorflow.python.framework import errors
from tensorflow.python.framework import ops
@@ -35,7 +36,6 @@ from tensorflow.python.framework import tensor_util
from tensorflow.python.framework import test_util
from tensorflow.python.framework import versions
from tensorflow.python.ops import array_ops
-from tensorflow.python.ops import constant_op
from tensorflow.python.ops import control_flow_ops
from tensorflow.python.ops import math_ops
from tensorflow.python.ops import state_ops
diff --git a/tensorflow/python/ops/common_shapes.py b/tensorflow/python/framework/common_shapes.py
index 6032a02f93..6032a02f93 100644
--- a/tensorflow/python/ops/common_shapes.py
+++ b/tensorflow/python/framework/common_shapes.py
diff --git a/tensorflow/python/framework/constant_op.py b/tensorflow/python/framework/constant_op.py
new file mode 100644
index 0000000000..21df625874
--- /dev/null
+++ b/tensorflow/python/framework/constant_op.py
@@ -0,0 +1,226 @@
+# Copyright 2015 The TensorFlow Authors. All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+# ==============================================================================
+
+"""## Constant Value Tensors
+
+TensorFlow provides several operations that you can use to generate constants.
+
+@@zeros
+@@zeros_like
+
+@@ones
+@@ones_like
+
+@@fill
+
+@@constant
+
+## Sequences
+
+@@linspace
+
+@@range
+
+## Random Tensors
+
+TensorFlow has several ops that create random tensors with different
+distributions. The random ops are stateful, and create new random values each
+time they are evaluated.
+
+The `seed` keyword argument in these functions acts in conjunction with
+the graph-level random seed. Changing either the graph-level seed using
+[`set_random_seed`](../../api_docs/python/constant_op.md#set_random_seed) or the
+op-level seed will change the underlying seed of these operations. Setting
+neither graph-level nor op-level seed, results in a random seed for all
+operations.
+See [`set_random_seed`](../../api_docs/python/constant_op.md#set_random_seed)
+for details on the interaction between operation-level and graph-level random
+seeds.
+
+### Examples:
+
+```python
+# Create a tensor of shape [2, 3] consisting of random normal values, with mean
+# -1 and standard deviation 4.
+norm = tf.random_normal([2, 3], mean=-1, stddev=4)
+
+# Shuffle the first dimension of a tensor
+c = tf.constant([[1, 2], [3, 4], [5, 6]])
+shuff = tf.random_shuffle(c)
+
+# Each time we run these ops, different results are generated
+sess = tf.Session()
+print(sess.run(norm))
+print(sess.run(norm))
+
+# Set an op-level seed to generate repeatable sequences across sessions.
+norm = tf.random_normal([2, 3], seed=1234)
+sess = tf.Session()
+print(sess.run(norm))
+print(sess.run(norm))
+sess = tf.Session()
+print(sess.run(norm))
+print(sess.run(norm))
+```
+
+Another common use of random values is the initialization of variables. Also see
+the [Variables How To](../../how_tos/variables/index.md).
+
+```python
+# Use random uniform values in [0, 1) as the initializer for a variable of shape
+# [2, 3]. The default type is float32.
+var = tf.Variable(tf.random_uniform([2, 3]), name="var")
+init = tf.initialize_all_variables()
+
+sess = tf.Session()
+sess.run(init)
+print(sess.run(var))
+```
+
+@@random_normal
+@@truncated_normal
+@@random_uniform
+@@random_shuffle
+@@random_crop
+@@multinomial
+@@set_random_seed
+"""
+
+# Must be separate from array_ops to avoid a cyclic dependency.
+
+from __future__ import absolute_import
+from __future__ import division
+from __future__ import print_function
+
+import numpy as np
+
+from tensorflow.core.framework import attr_value_pb2
+from tensorflow.python.framework import dtypes
+from tensorflow.python.framework import ops
+from tensorflow.python.framework import tensor_shape
+from tensorflow.python.framework import tensor_util
+
+
+def constant(value, dtype=None, shape=None, name="Const"):
+ """Creates a constant tensor.
+
+ The resulting tensor is populated with values of type `dtype`, as
+ specified by arguments `value` and (optionally) `shape` (see examples
+ below).
+
+ The argument `value` can be a constant value, or a list of values of type
+ `dtype`. If `value` is a list, then the length of the list must be less
+ than or equal to the number of elements implied by the `shape` argument (if
+ specified). In the case where the list length is less than the number of
+ elements specified by `shape`, the last element in the list will be used
+ to fill the remaining entries.
+
+ The argument `shape` is optional. If present, it specifies the dimensions of
+ the resulting tensor. If not present, the shape of `value` is used.
+
+ If the argument `dtype` is not specified, then the type is inferred from
+ the type of `value`.
+
+ For example:
+
+ ```python
+ # Constant 1-D Tensor populated with value list.
+ tensor = tf.constant([1, 2, 3, 4, 5, 6, 7]) => [1 2 3 4 5 6 7]
+
+ # Constant 2-D tensor populated with scalar value -1.
+ tensor = tf.constant(-1.0, shape=[2, 3]) => [[-1. -1. -1.]
+ [-1. -1. -1.]]
+ ```
+
+ Args:
+ value: A constant value (or list) of output type `dtype`.
+
+ dtype: The type of the elements of the resulting tensor.
+
+ shape: Optional dimensions of resulting tensor.
+
+ name: Optional name for the tensor.
+
+ Returns:
+ A Constant Tensor.
+ """
+ g = ops.get_default_graph()
+ tensor_value = attr_value_pb2.AttrValue()
+ tensor_value.tensor.CopyFrom(
+ tensor_util.make_tensor_proto(value, dtype=dtype, shape=shape))
+ dtype_value = attr_value_pb2.AttrValue(type=tensor_value.tensor.dtype)
+ const_tensor = g.create_op(
+ "Const", [], [dtype_value.type],
+ attrs={"value": tensor_value, "dtype": dtype_value}, name=name).outputs[0]
+ return const_tensor
+
+
+@ops.RegisterShape("Const")
+def _ConstantShape(op):
+ return [tensor_shape.TensorShape(
+ [d.size for d in op.get_attr("value").tensor_shape.dim])]
+
+
+def _constant_tensor_conversion_function(v, dtype=None, name=None,
+ as_ref=False):
+ _ = as_ref
+ return constant(v, dtype=dtype, name=name)
+
+
+ops.register_tensor_conversion_function(
+ (list, tuple), _constant_tensor_conversion_function, 100)
+ops.register_tensor_conversion_function(
+ np.ndarray, _constant_tensor_conversion_function, 100)
+ops.register_tensor_conversion_function(
+ np.generic, _constant_tensor_conversion_function, 100)
+ops.register_tensor_conversion_function(
+ object, _constant_tensor_conversion_function, 200)
+
+
+def _tensor_shape_tensor_conversion_function(s, dtype=None, name=None,
+ as_ref=False):
+ _ = as_ref
+ if not s.is_fully_defined():
+ raise ValueError(
+ "Cannot convert a partially known TensorShape to a Tensor: %s" % s)
+ if dtype is not None:
+ if dtype not in (dtypes.int32, dtypes.int64):
+ raise TypeError("Cannot convert a TensorShape to dtype: %s" % dtype)
+ else:
+ dtype = dtypes.int32
+ if name is None:
+ name = "shape_as_tensor"
+ return constant(s.as_list(), dtype=dtype, name=name)
+
+ops.register_tensor_conversion_function(
+ tensor_shape.TensorShape, _tensor_shape_tensor_conversion_function, 100)
+
+
+def _dimension_tensor_conversion_function(d, dtype=None, name=None,
+ as_ref=False):
+ _ = as_ref
+ if d.value is None:
+ raise ValueError("Cannot convert an unknown Dimension to a Tensor: %s" % d)
+ if dtype is not None:
+ if dtype not in (dtypes.int32, dtypes.int64):
+ raise TypeError("Cannot convert a TensorShape to dtype: %s" % dtype)
+ else:
+ dtype = dtypes.int32
+ if name is None:
+ name = "shape_as_tensor"
+ return constant(d.value, dtype=dtype, name=name)
+
+ops.register_tensor_conversion_function(
+ tensor_shape.Dimension, _dimension_tensor_conversion_function, 100)
diff --git a/tensorflow/python/framework/gen_docs_combined.py b/tensorflow/python/framework/gen_docs_combined.py
index b69294c571..a7f30d83b5 100644
--- a/tensorflow/python/framework/gen_docs_combined.py
+++ b/tensorflow/python/framework/gen_docs_combined.py
@@ -25,6 +25,7 @@ import tensorflow as tf
from tensorflow.contrib import ffmpeg
from tensorflow.python.client import client_lib
+from tensorflow.python.framework import constant_op
from tensorflow.python.framework import docs
from tensorflow.python.framework import framework_lib
@@ -92,36 +93,45 @@ def all_libraries(module_to_name, members, documented):
library("framework", "Building Graphs", framework_lib),
library("check_ops", "Asserts and boolean checks."),
library("constant_op", "Constants, Sequences, and Random Values",
- prefix=PREFIX_TEXT),
- library("state_ops", "Variables",
+ constant_op, prefix=PREFIX_TEXT),
+ library("state_ops",
+ "Variables",
exclude_symbols=["create_partitioned_variables"],
prefix=PREFIX_TEXT),
- library("array_ops", "Tensor Transformations",
- exclude_symbols=["list_diff"], prefix=PREFIX_TEXT),
- library("math_ops", "Math",
+ library("array_ops",
+ "Tensor Transformations",
+ exclude_symbols=["list_diff"],
+ prefix=PREFIX_TEXT),
+ library("math_ops",
+ "Math",
exclude_symbols=["sparse_matmul", "arg_min", "arg_max",
"lin_space", "sparse_segment_mean_grad"],
prefix=PREFIX_TEXT),
- library("string_ops", "Strings", prefix=PREFIX_TEXT),
+ library("string_ops", "Strings",
+ prefix=PREFIX_TEXT),
library("histogram_ops", "Histograms"),
library("control_flow_ops", "Control Flow", prefix=PREFIX_TEXT),
library("functional_ops", "Higher Order Functions", prefix=PREFIX_TEXT),
library("tensor_array_ops", "TensorArray Operations", prefix=PREFIX_TEXT),
library("session_ops", "Tensor Handle Operations", prefix=PREFIX_TEXT),
library("image", "Images", tf.image, exclude_symbols=["ResizeMethod"],
- prefix=PREFIX_TEXT),
- library("sparse_ops", "Sparse Tensors",
+ prefix=PREFIX_TEXT),
+ library("sparse_ops",
+ "Sparse Tensors",
exclude_symbols=["serialize_sparse", "serialize_many_sparse",
"deserialize_many_sparse"],
prefix=PREFIX_TEXT),
- library("io_ops", "Inputs and Readers",
+ library("io_ops",
+ "Inputs and Readers",
exclude_symbols=["LookupTableBase", "HashTable",
"initialize_all_tables",
"parse_single_sequence_example",
"string_to_hash_bucket"],
prefix=PREFIX_TEXT),
library("python_io", "Data IO (Python functions)", tf.python_io),
- library("nn", "Neural Network", tf.nn,
+ library("nn",
+ "Neural Network",
+ tf.nn,
exclude_symbols=["conv2d_backprop_input",
"conv2d_backprop_filter", "avg_pool_grad",
"max_pool_grad", "max_pool_grad_with_argmax",
@@ -130,18 +140,22 @@ def all_libraries(module_to_name, members, documented):
"softsign_grad", "xw_plus_b", "relu_layer",
"lrn", "batch_norm_with_global_normalization",
"batch_norm_with_global_normalization_grad",
- "all_candidate_sampler",
- "rnn", "state_saving_rnn", "bidirectional_rnn",
+ "all_candidate_sampler", "rnn",
+ "state_saving_rnn", "bidirectional_rnn",
"dynamic_rnn", "seq2seq", "rnn_cell"],
prefix=PREFIX_TEXT),
library("rnn_cell", "Neural Network RNN Cells", tf.nn.rnn_cell),
library("client", "Running Graphs", client_lib),
- library("train", "Training", tf.train,
+ library("train",
+ "Training",
+ tf.train,
exclude_symbols=["Feature", "Features", "BytesList", "FloatList",
"Int64List", "Example", "InferenceExample",
- "FeatureList", "FeatureLists",
- "RankingExample", "SequenceExample"]),
- library("script_ops", "Wraps python functions", prefix=PREFIX_TEXT),
+ "FeatureList", "FeatureLists", "RankingExample",
+ "SequenceExample"]),
+ library("script_ops",
+ "Wraps python functions",
+ prefix=PREFIX_TEXT),
library("test", "Testing", tf.test),
library("contrib.bayesflow.stochastic_graph",
"BayesFlow Stochastic Graph (contrib)",
@@ -157,7 +171,7 @@ def all_libraries(module_to_name, members, documented):
library("contrib.util", "Utilities (contrib)", tf.contrib.util),
library("contrib.copy_graph", "Copying Graph Elements (contrib)",
tf.contrib.copy_graph),
- ]
+ ]
_hidden_symbols = ["Event", "LogMessage", "Summary", "SessionLog", "xrange",
"HistogramProto", "ConfigProto", "NodeDef", "GraphDef",
diff --git a/tensorflow/python/client/graph_util.py b/tensorflow/python/framework/graph_util.py
index 8b458933d6..8b458933d6 100644
--- a/tensorflow/python/client/graph_util.py
+++ b/tensorflow/python/framework/graph_util.py
diff --git a/tensorflow/python/client/graph_util_test.py b/tensorflow/python/framework/graph_util_test.py
index b7fb8efcc5..4d09d4c8d4 100644
--- a/tensorflow/python/client/graph_util_test.py
+++ b/tensorflow/python/framework/graph_util_test.py
@@ -20,10 +20,10 @@ from __future__ import print_function
import tensorflow as tf
-from tensorflow.python.client import graph_util
+from tensorflow.python.framework import constant_op
from tensorflow.python.framework import dtypes
+from tensorflow.python.framework import graph_util
from tensorflow.python.framework import ops
-from tensorflow.python.ops import constant_op
from tensorflow.python.ops import math_ops # pylint: disable=unused-import
from tensorflow.python.ops import state_ops
diff --git a/tensorflow/python/ops/op_def_library.py b/tensorflow/python/framework/op_def_library.py
index 156d15c9e9..e495b3d8a9 100644
--- a/tensorflow/python/ops/op_def_library.py
+++ b/tensorflow/python/framework/op_def_library.py
@@ -31,7 +31,6 @@ from tensorflow.core.framework import types_pb2
from tensorflow.python.framework import dtypes
from tensorflow.python.framework import ops
from tensorflow.python.framework import tensor_shape
-from tensorflow.python.ops import constant_op
from tensorflow.python.platform import tf_logging as logging
from tensorflow.python.util import compat
diff --git a/tensorflow/python/ops/op_def_library_test.py b/tensorflow/python/framework/op_def_library_test.py
index 83ca6d1ec3..27933cc193 100644
--- a/tensorflow/python/ops/op_def_library_test.py
+++ b/tensorflow/python/framework/op_def_library_test.py
@@ -25,9 +25,9 @@ from tensorflow.core.framework import op_def_pb2
from tensorflow.core.framework import tensor_shape_pb2
from tensorflow.python.framework import dtypes
from tensorflow.python.framework import ops
-from tensorflow.python.framework import test_util
from tensorflow.python.framework import tensor_shape
-from tensorflow.python.ops.op_def_library import OpDefLibrary
+from tensorflow.python.framework import test_util
+from tensorflow.python.framework.op_def_library import OpDefLibrary
from tensorflow.python.platform import googletest
@@ -303,8 +303,7 @@ class OpDefLibraryTest(test_util.TensorFlowTestCase):
attr { key: 'T' value { type: DT_STRING } }
""", out.op.node_def)
- out = self._lib.apply_op("PolymorphicDefaultOut", T=dtypes.bool,
- name="q")
+ out = self._lib.apply_op("PolymorphicDefaultOut", T=dtypes.bool, name="q")
self.assertEqual(dtypes.bool, out.dtype)
self.assertProtoEquals("""
name: 'q' op: 'PolymorphicDefaultOut'
@@ -338,8 +337,9 @@ class OpDefLibraryTest(test_util.TensorFlowTestCase):
"Expected string, got 12 of type 'int' instead.")
with self.assertRaises(TypeError) as cm:
- self._lib.apply_op("Binary", a=self.Tensor(dtypes.string),
- b=self.Tensor(dtypes.int32))
+ self._lib.apply_op("Binary",
+ a=self.Tensor(dtypes.string),
+ b=self.Tensor(dtypes.int32))
self.assertEqual(str(cm.exception),
"Input 'b' of 'Binary' Op has type int32 "
"that does not match type string of argument 'a'.")
@@ -412,8 +412,10 @@ class OpDefLibraryTest(test_util.TensorFlowTestCase):
"input_arg { name: 'b' type_list_attr: 'T' } "
"attr { name: 'T' type: 'list(type)' }")
- op = self._lib.apply_op("TypeListTwice", a=["foo", True], b=["bar", False],
- name="z")
+ op = self._lib.apply_op("TypeListTwice",
+ a=["foo", True],
+ b=["bar", False],
+ name="z")
self.assertProtoEquals("""
name: 'z' op: 'TypeListTwice'
input: 'z/a_0' input: 'z/a_1' input: 'z/b_0' input: 'z/b_1'
@@ -445,8 +447,8 @@ class OpDefLibraryTest(test_util.TensorFlowTestCase):
""", out.op.node_def)
out1, out2 = self._lib.apply_op("OutTypeList",
- T=[dtypes.int32, dtypes.bool],
- name="w")
+ T=[dtypes.int32, dtypes.bool],
+ name="w")
self.assertEqual(dtypes.int32, out1.dtype)
self.assertEqual(dtypes.bool, out2.dtype)
self.assertProtoEquals("""
@@ -486,8 +488,8 @@ class OpDefLibraryTest(test_util.TensorFlowTestCase):
" type: DT_STRING type: DT_BOOL } } }")
out1, out2 = self._lib.apply_op("OutTypeListRestrict",
- t=[dtypes.bool, dtypes.string],
- name="u")
+ t=[dtypes.bool, dtypes.string],
+ name="u")
self.assertEqual(dtypes.bool, out1.dtype)
self.assertEqual(dtypes.string, out2.dtype)
self.assertProtoEquals("""
@@ -496,8 +498,7 @@ class OpDefLibraryTest(test_util.TensorFlowTestCase):
""", out1.op.node_def)
with self.assertRaises(TypeError) as cm:
- self._lib.apply_op("OutTypeListRestrict",
- t=[dtypes.string, dtypes.int32])
+ self._lib.apply_op("OutTypeListRestrict", t=[dtypes.string, dtypes.int32])
self.assertEqual(str(cm.exception),
"DataType int32 for attr 't' "
"not in list of allowed values: string, bool")
@@ -774,7 +775,7 @@ class OpDefLibraryTest(test_util.TensorFlowTestCase):
# "Don't know how to convert 5 to a TensorShapeProto for "
# "argument 'a'")
- with self.assertRaises(TypeError) as cm:
+ with self.assertRaises(TypeError):
self._lib.apply_op("AttrPartialShape", a="ABC")
def testAttrPartialShapeList(self):
@@ -892,8 +893,9 @@ class OpDefLibraryTest(test_util.TensorFlowTestCase):
"[string, string] that do not match expected type int32.")
with self.assertRaises(TypeError) as cm:
- self._lib.apply_op("NIntsIn", a=[self.Tensor(dtypes.string),
- self.Tensor(dtypes.string)])
+ self._lib.apply_op("NIntsIn",
+ a=[self.Tensor(dtypes.string),
+ self.Tensor(dtypes.string)])
self.assertEqual(str(cm.exception),
"Tensors in list passed to 'a' of 'NIntsIn' Op have "
"types [string, string] that do not match expected type "
@@ -913,8 +915,9 @@ class OpDefLibraryTest(test_util.TensorFlowTestCase):
"[int32, string] that do not match expected type int32.")
with self.assertRaises(TypeError) as cm:
- self._lib.apply_op("NIntsIn", a=[self.Tensor(dtypes.int32),
- self.Tensor(dtypes.string)])
+ self._lib.apply_op("NIntsIn",
+ a=[self.Tensor(dtypes.int32),
+ self.Tensor(dtypes.string)])
self.assertEqual(str(cm.exception),
"Tensors in list passed to 'a' of 'NIntsIn' Op "
"have types [int32, string] that do not match expected "
@@ -955,8 +958,8 @@ class OpDefLibraryTest(test_util.TensorFlowTestCase):
""", op.node_def)
op = self._lib.apply_op("NPolymorphicIn",
- a=[1, self.Tensor(dtypes.float32, name="x")],
- name="q")
+ a=[1, self.Tensor(dtypes.float32, name="x")],
+ name="q")
self.assertProtoEquals("""
name: 'q' op: 'NPolymorphicIn' input: 'q/a_0' input: 'x'
attr { key: 'T' value { type: DT_FLOAT } }
@@ -986,8 +989,7 @@ class OpDefLibraryTest(test_util.TensorFlowTestCase):
"have types [int32, string] that don't all match.")
with self.assertRaises(TypeError) as cm:
- self._lib.apply_op("NPolymorphicIn",
- a=[38, self.Tensor(dtypes.string)])
+ self._lib.apply_op("NPolymorphicIn", a=[38, self.Tensor(dtypes.string)])
self.assertEqual(str(cm.exception),
"Tensors in list passed to 'a' of 'NPolymorphicIn' Op "
"have types [int32, string] that don't all match.")
@@ -1001,7 +1003,7 @@ class OpDefLibraryTest(test_util.TensorFlowTestCase):
with self.assertRaises(TypeError) as cm:
self._lib.apply_op("NPolymorphicIn",
- a=["abcd", self.Tensor(dtypes.int32)])
+ a=["abcd", self.Tensor(dtypes.int32)])
self.assertEqual(str(cm.exception),
"Tensors in list passed to 'a' of 'NPolymorphicIn' Op "
"have types [string, int32] that don't all match.")
@@ -1027,8 +1029,9 @@ class OpDefLibraryTest(test_util.TensorFlowTestCase):
attr { key: 'N' value { i: 2 } }
""", op.node_def)
- op = self._lib.apply_op("NPolymorphicRestrictIn", a=[False, True, False],
- name="b")
+ op = self._lib.apply_op("NPolymorphicRestrictIn",
+ a=[False, True, False],
+ name="b")
self.assertProtoEquals("""
name: 'b' op: 'NPolymorphicRestrictIn'
input: 'b/a_0' input: 'b/a_1' input: 'b/a_2'
@@ -1098,8 +1101,8 @@ class OpDefLibraryTest(test_util.TensorFlowTestCase):
with self.assertRaises(TypeError) as cm:
self._lib.apply_op("NInPolymorphicTwice",
- a=[self.Tensor(dtypes.int32)],
- b=[self.Tensor(dtypes.string)])
+ a=[self.Tensor(dtypes.int32)],
+ b=[self.Tensor(dtypes.string)])
self.assertEqual(str(cm.exception),
"Tensors in list passed to 'b' of "
"'NInPolymorphicTwice' Op have types [string] that do not "
@@ -1113,8 +1116,10 @@ class OpDefLibraryTest(test_util.TensorFlowTestCase):
"attr { name: 'T' type: 'type' } "
"attr { name: 'N' type: 'int' has_minimum: true minimum: 0 }")
- op = self._lib.apply_op("NInTwoTypeVariables", a=[1, 2], b=[True, False],
- name="n")
+ op = self._lib.apply_op("NInTwoTypeVariables",
+ a=[1, 2],
+ b=[True, False],
+ name="n")
self.assertProtoEquals("""
name: 'n' op: 'NInTwoTypeVariables'
input: 'n/a_0' input: 'n/a_1' input: 'n/b_0' input: 'n/b_1'
@@ -1133,9 +1138,9 @@ class OpDefLibraryTest(test_util.TensorFlowTestCase):
""", op.node_def)
op = self._lib.apply_op("NInTwoTypeVariables",
- a=[self.Tensor(dtypes.int32, name="q")],
- b=[self.Tensor(dtypes.string, name="r")],
- name="p")
+ a=[self.Tensor(dtypes.int32, name="q")],
+ b=[self.Tensor(dtypes.string, name="r")],
+ name="p")
self.assertProtoEquals("""
name: 'p' op: 'NInTwoTypeVariables' input: 'q' input: 'r'
attr { key: 'S' value { type: DT_INT32 } }
@@ -1190,8 +1195,8 @@ class OpDefLibraryTest(test_util.TensorFlowTestCase):
with self.assertRaises(TypeError) as cm:
self._lib.apply_op("InPolymorphicTwice",
- a=[self.Tensor(dtypes.int32)],
- b=[self.Tensor(dtypes.string)])
+ a=[self.Tensor(dtypes.int32)],
+ b=[self.Tensor(dtypes.string)])
self.assertEqual(str(cm.exception),
"Tensors in list passed to 'b' of 'InPolymorphicTwice' "
"Op have types [string] that do not match type int32 "
@@ -1258,8 +1263,10 @@ class OpDefLibraryTest(test_util.TensorFlowTestCase):
"attr { name: 'T' type: 'type' } "
"attr { name: 'N' type: 'int' has_minimum: true minimum: 2 }")
- out1, out2 = self._lib.apply_op("NPolymorphicOut", N=2,
- T=dtypes.int32, name="n")
+ out1, out2 = self._lib.apply_op("NPolymorphicOut",
+ N=2,
+ T=dtypes.int32,
+ name="n")
self.assertEqual(dtypes.int32, out1.dtype)
self.assertEqual(dtypes.int32, out2.dtype)
self.assertProtoEquals("""
@@ -1461,7 +1468,9 @@ class OpDefLibraryTest(test_util.TensorFlowTestCase):
[dtypes.int32],
[dtypes.int32, dtypes.float32]]:
a, b, c = self._lib.apply_op("ComplexStruct",
- n_a=n_a, n_b=n_b, t_c=t_c)
+ n_a=n_a,
+ n_b=n_b,
+ t_c=t_c)
self.assertEqual(n_a, len(a))
self.assertTrue(all(x.dtype == dtypes.int32 for x in a))
diff --git a/tensorflow/python/framework/ops_test.py b/tensorflow/python/framework/ops_test.py
index 36bc73644a..1d1ed97052 100644
--- a/tensorflow/python/framework/ops_test.py
+++ b/tensorflow/python/framework/ops_test.py
@@ -18,6 +18,8 @@ from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
+from tensorflow.python.framework import common_shapes
+from tensorflow.python.framework import constant_op
from tensorflow.python.framework import device as pydev
from tensorflow.python.framework import dtypes
from tensorflow.python.framework import errors
@@ -26,8 +28,6 @@ from tensorflow.python.framework import tensor_shape
from tensorflow.python.framework import test_ops
from tensorflow.python.framework import test_util
from tensorflow.python.framework import versions
-from tensorflow.python.ops import common_shapes
-from tensorflow.python.ops import constant_op
# Import gradients to register _IndexedSlicesToTensor.
import tensorflow.python.ops.gradients # pylint: disable=unused-import
from tensorflow.python.ops import math_ops
diff --git a/tensorflow/python/framework/python_op_gen.cc b/tensorflow/python/framework/python_op_gen.cc
index aa198da328..708170d9c1 100644
--- a/tensorflow/python/framework/python_op_gen.cc
+++ b/tensorflow/python/framework/python_op_gen.cc
@@ -663,7 +663,7 @@ from google.protobuf import text_format
from tensorflow.core.framework import op_def_pb2
from tensorflow.python.framework import op_def_registry
from tensorflow.python.framework import ops
-from tensorflow.python.ops import op_def_library
+from tensorflow.python.framework import op_def_library
)");
diff --git a/tensorflow/python/framework/test_util_test.py b/tensorflow/python/framework/test_util_test.py
index 791538b166..205067cc0f 100644
--- a/tensorflow/python/framework/test_util_test.py
+++ b/tensorflow/python/framework/test_util_test.py
@@ -27,11 +27,11 @@ import tensorflow as tf
from google.protobuf import text_format
from tensorflow.core.framework import graph_pb2
+from tensorflow.python.framework import constant_op
from tensorflow.python.framework import errors
from tensorflow.python.framework import ops
from tensorflow.python.framework import test_util
from tensorflow.python.platform import googletest
-from tensorflow.python.ops import constant_op
from tensorflow.python.ops import logging_ops
diff --git a/tensorflow/python/kernel_tests/gradient_checker.py b/tensorflow/python/kernel_tests/gradient_checker.py
index f317124bc2..c5bd166887 100644
--- a/tensorflow/python/kernel_tests/gradient_checker.py
+++ b/tensorflow/python/kernel_tests/gradient_checker.py
@@ -24,10 +24,10 @@ from __future__ import print_function
import numpy as np
+from tensorflow.python.framework import constant_op
from tensorflow.python.framework import dtypes
from tensorflow.python.framework import ops
from tensorflow.python.ops import array_ops
-from tensorflow.python.ops import constant_op
from tensorflow.python.ops import gradients
from tensorflow.python.platform import tf_logging as logging
diff --git a/tensorflow/python/kernel_tests/sparse_ops_test.py b/tensorflow/python/kernel_tests/sparse_ops_test.py
index dfbe448198..867bfc5b36 100644
--- a/tensorflow/python/kernel_tests/sparse_ops_test.py
+++ b/tensorflow/python/kernel_tests/sparse_ops_test.py
@@ -22,11 +22,11 @@ from __future__ import print_function
import numpy as np
import tensorflow as tf
+from tensorflow.python.framework import constant_op
from tensorflow.python.framework import dtypes
from tensorflow.python.framework import ops
from tensorflow.python.framework import test_util
from tensorflow.python.ops import array_ops
-from tensorflow.python.ops import constant_op
from tensorflow.python.ops import sparse_ops
from tensorflow.python.platform import googletest
diff --git a/tensorflow/python/ops/array_grad.py b/tensorflow/python/ops/array_grad.py
index 2a58ac991c..5776ac1f1b 100644
--- a/tensorflow/python/ops/array_grad.py
+++ b/tensorflow/python/ops/array_grad.py
@@ -19,10 +19,10 @@ from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
+from tensorflow.python.framework import constant_op
from tensorflow.python.framework import ops
from tensorflow.python.framework import tensor_util
from tensorflow.python.ops import array_ops
-from tensorflow.python.ops import constant_op
from tensorflow.python.ops import gen_array_ops
from tensorflow.python.ops import math_ops
diff --git a/tensorflow/python/ops/array_ops.py b/tensorflow/python/ops/array_ops.py
index fd442c6eb8..1f33ceb745 100644
--- a/tensorflow/python/ops/array_ops.py
+++ b/tensorflow/python/ops/array_ops.py
@@ -75,17 +75,17 @@ from __future__ import print_function
import sys
import numpy as np
+from tensorflow.python.framework import common_shapes
+from tensorflow.python.framework import constant_op
from tensorflow.python.framework import dtypes
from tensorflow.python.framework import ops
from tensorflow.python.framework import tensor_shape
from tensorflow.python.framework import tensor_util
-from tensorflow.python.ops import common_shapes
-from tensorflow.python.ops import constant_op
+# 'Constant' gets imported in the module 'array_ops'.
+from tensorflow.python.framework.constant_op import constant
from tensorflow.python.ops import gen_array_ops
from tensorflow.python.ops import gen_math_ops
from tensorflow.python.ops import logging_ops
-# 'Constant' gets imported in the module 'array_ops'.
-from tensorflow.python.ops.constant_op import constant
# go/tf-wildcard-import
# pylint: disable=wildcard-import
from tensorflow.python.ops.gen_array_ops import *
diff --git a/tensorflow/python/ops/clip_ops.py b/tensorflow/python/ops/clip_ops.py
index 5b2de5a0aa..dd6b46d42f 100644
--- a/tensorflow/python/ops/clip_ops.py
+++ b/tensorflow/python/ops/clip_ops.py
@@ -22,10 +22,10 @@ import collections
import six
+from tensorflow.python.framework import constant_op
from tensorflow.python.framework import dtypes
from tensorflow.python.framework import ops
from tensorflow.python.ops import array_ops
-from tensorflow.python.ops import constant_op
from tensorflow.python.ops import math_ops
from tensorflow.python.ops import nn_ops
diff --git a/tensorflow/python/ops/control_flow_ops.py b/tensorflow/python/ops/control_flow_ops.py
index b61dcfa7d5..6d79af93ed 100644
--- a/tensorflow/python/ops/control_flow_ops.py
+++ b/tensorflow/python/ops/control_flow_ops.py
@@ -75,12 +75,12 @@ import collections
import six
from six.moves import xrange # pylint: disable=redefined-builtin
+from tensorflow.python.framework import common_shapes
+from tensorflow.python.framework import constant_op
from tensorflow.python.framework import dtypes
from tensorflow.python.framework import ops
from tensorflow.python.framework import tensor_shape
from tensorflow.python.ops import array_ops
-from tensorflow.python.ops import common_shapes
-from tensorflow.python.ops import constant_op
from tensorflow.python.ops import gen_array_ops
from tensorflow.python.ops import gen_control_flow_ops
from tensorflow.python.ops import gen_data_flow_ops
diff --git a/tensorflow/python/ops/data_flow_grad.py b/tensorflow/python/ops/data_flow_grad.py
index af04d41f02..8fea075038 100644
--- a/tensorflow/python/ops/data_flow_grad.py
+++ b/tensorflow/python/ops/data_flow_grad.py
@@ -23,7 +23,6 @@ from six.moves import xrange # pylint: disable=redefined-builtin
from tensorflow.python.framework import dtypes
from tensorflow.python.framework import ops
from tensorflow.python.ops import array_ops
-from tensorflow.python.ops import constant_op
from tensorflow.python.ops import data_flow_ops
from tensorflow.python.ops import math_ops
diff --git a/tensorflow/python/ops/data_flow_ops.py b/tensorflow/python/ops/data_flow_ops.py
index 5f53b3dbc5..fabe7892cb 100644
--- a/tensorflow/python/ops/data_flow_ops.py
+++ b/tensorflow/python/ops/data_flow_ops.py
@@ -22,12 +22,12 @@ from __future__ import print_function
import collections
import re
+from tensorflow.python.framework import common_shapes
from tensorflow.python.framework import ops
from tensorflow.python.framework import random_seed
from tensorflow.python.framework import tensor_shape
from tensorflow.python.framework import tensor_util
from tensorflow.python.ops import array_ops
-from tensorflow.python.ops import common_shapes
from tensorflow.python.ops import control_flow_ops
from tensorflow.python.ops import gen_data_flow_ops
# go/tf-wildcard-import
diff --git a/tensorflow/python/ops/embedding_ops.py b/tensorflow/python/ops/embedding_ops.py
index 30c0638e05..f918aec4b0 100644
--- a/tensorflow/python/ops/embedding_ops.py
+++ b/tensorflow/python/ops/embedding_ops.py
@@ -20,10 +20,10 @@ from __future__ import print_function
from six.moves import xrange # pylint: disable=redefined-builtin
+from tensorflow.python.framework import constant_op
from tensorflow.python.framework import dtypes
from tensorflow.python.framework import ops
from tensorflow.python.ops import array_ops
-from tensorflow.python.ops import constant_op
from tensorflow.python.ops import data_flow_ops
from tensorflow.python.ops import math_ops
diff --git a/tensorflow/python/ops/functional_ops.py b/tensorflow/python/ops/functional_ops.py
index 4fd5caa902..72f52bc063 100644
--- a/tensorflow/python/ops/functional_ops.py
+++ b/tensorflow/python/ops/functional_ops.py
@@ -30,9 +30,9 @@ from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
+from tensorflow.python.framework import constant_op
from tensorflow.python.framework import ops
from tensorflow.python.ops import array_ops
-from tensorflow.python.ops import constant_op
from tensorflow.python.ops import control_flow_ops
from tensorflow.python.ops import tensor_array_ops
from tensorflow.python.ops import variable_scope as vs
diff --git a/tensorflow/python/ops/gradients.py b/tensorflow/python/ops/gradients.py
index d6ab689f20..41fb92c8fa 100644
--- a/tensorflow/python/ops/gradients.py
+++ b/tensorflow/python/ops/gradients.py
@@ -25,13 +25,13 @@ import warnings
import numpy as np
from six.moves import xrange # pylint: disable=redefined-builtin
+from tensorflow.python.framework import constant_op
from tensorflow.python.framework import dtypes
from tensorflow.python.framework import ops
from tensorflow.python.framework import tensor_shape
from tensorflow.python.framework import tensor_util
from tensorflow.python.ops import array_grad # pylint: disable=unused-import
from tensorflow.python.ops import array_ops
-from tensorflow.python.ops import constant_op
from tensorflow.python.ops import control_flow_grad # pylint: disable=unused-import
from tensorflow.python.ops import control_flow_ops
from tensorflow.python.ops import image_grad # pylint: disable=unused-import
diff --git a/tensorflow/python/ops/gradients_test.py b/tensorflow/python/ops/gradients_test.py
index 7560cbdecd..d1cf302901 100644
--- a/tensorflow/python/ops/gradients_test.py
+++ b/tensorflow/python/ops/gradients_test.py
@@ -23,13 +23,14 @@ import warnings
import numpy as np
import tensorflow as tf
+from tensorflow.python.framework import constant_op
from tensorflow.python.framework import dtypes
from tensorflow.python.framework import function
from tensorflow.python.framework import ops
from tensorflow.python.framework import test_util
+from tensorflow.python.framework.constant_op import constant
from tensorflow.python.ops import array_grad # pylint: disable=unused-import
from tensorflow.python.ops import array_ops
-from tensorflow.python.ops import constant_op
from tensorflow.python.ops import data_flow_grad # pylint: disable=unused-import
from tensorflow.python.ops import data_flow_ops # pylint: disable=unused-import
from tensorflow.python.ops import gradients
@@ -37,7 +38,6 @@ from tensorflow.python.ops import math_grad # pylint: disable=unused-import
from tensorflow.python.ops import math_ops
from tensorflow.python.ops import nn_grad # pylint: disable=unused-import
from tensorflow.python.ops import state_grad # pylint: disable=unused-import
-from tensorflow.python.ops.constant_op import constant
from tensorflow.python.ops import functional_ops # pylint: disable=unused-import
from tensorflow.python.ops.nn_ops import bias_add
diff --git a/tensorflow/python/ops/image_ops.py b/tensorflow/python/ops/image_ops.py
index bd0ee7344e..4045f8f2bd 100644
--- a/tensorflow/python/ops/image_ops.py
+++ b/tensorflow/python/ops/image_ops.py
@@ -157,13 +157,13 @@ from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
+from tensorflow.python.framework import common_shapes
from tensorflow.python.framework import dtypes
from tensorflow.python.framework import ops
from tensorflow.python.framework import tensor_shape
from tensorflow.python.framework import tensor_util
from tensorflow.python.ops import array_ops
from tensorflow.python.ops import clip_ops
-from tensorflow.python.ops import common_shapes
from tensorflow.python.ops import gen_image_ops
from tensorflow.python.ops import gen_nn_ops
from tensorflow.python.ops import math_ops
diff --git a/tensorflow/python/ops/image_ops_test.py b/tensorflow/python/ops/image_ops_test.py
index f47fa89a85..db29f74045 100644
--- a/tensorflow/python/ops/image_ops_test.py
+++ b/tensorflow/python/ops/image_ops_test.py
@@ -24,10 +24,10 @@ import os
import numpy as np
from six.moves import xrange # pylint: disable=redefined-builtin
-from tensorflow.python.framework import test_util
+from tensorflow.python.framework import constant_op
from tensorflow.python.framework import dtypes
+from tensorflow.python.framework import test_util
from tensorflow.python.ops import array_ops
-from tensorflow.python.ops import constant_op
from tensorflow.python.ops import image_ops
from tensorflow.python.ops import io_ops
from tensorflow.python.platform import googletest
diff --git a/tensorflow/python/ops/init_ops.py b/tensorflow/python/ops/init_ops.py
index 72245ee1fc..49cb5f146c 100644
--- a/tensorflow/python/ops/init_ops.py
+++ b/tensorflow/python/ops/init_ops.py
@@ -19,9 +19,9 @@ from __future__ import division
from __future__ import print_function
import math
+from tensorflow.python.framework import constant_op
from tensorflow.python.framework import dtypes
from tensorflow.python.ops import array_ops
-from tensorflow.python.ops import constant_op
from tensorflow.python.ops import math_ops
from tensorflow.python.ops import nn_ops
from tensorflow.python.ops import random_ops
diff --git a/tensorflow/python/ops/io_ops.py b/tensorflow/python/ops/io_ops.py
index 96cdff2af4..a5ed7d7a49 100644
--- a/tensorflow/python/ops/io_ops.py
+++ b/tensorflow/python/ops/io_ops.py
@@ -133,10 +133,10 @@ from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
+from tensorflow.python.framework import common_shapes
from tensorflow.python.framework import dtypes
from tensorflow.python.framework import ops
from tensorflow.python.framework import tensor_shape
-from tensorflow.python.ops import common_shapes
from tensorflow.python.ops import gen_io_ops
# go/tf-wildcard-import
# pylint: disable=wildcard-import
diff --git a/tensorflow/python/ops/linalg_grad.py b/tensorflow/python/ops/linalg_grad.py
index 3615f6f364..0d9650f6c5 100644
--- a/tensorflow/python/ops/linalg_grad.py
+++ b/tensorflow/python/ops/linalg_grad.py
@@ -28,7 +28,6 @@ from tensorflow.python.framework import ops
from tensorflow.python.framework import tensor_shape
from tensorflow.python.ops import array_ops
from tensorflow.python.ops import control_flow_ops
-from tensorflow.python.ops import constant_op
from tensorflow.python.ops import linalg_ops
from tensorflow.python.ops import math_ops
diff --git a/tensorflow/python/ops/logging_ops.py b/tensorflow/python/ops/logging_ops.py
index 8fce9f5ca1..3ccd3db98c 100644
--- a/tensorflow/python/ops/logging_ops.py
+++ b/tensorflow/python/ops/logging_ops.py
@@ -19,9 +19,9 @@ from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
+from tensorflow.python.framework import common_shapes
from tensorflow.python.framework import ops
from tensorflow.python.framework import tensor_shape
-from tensorflow.python.ops import common_shapes
from tensorflow.python.ops import gen_logging_ops
# go/tf-wildcard-import
# pylint: disable=wildcard-import
diff --git a/tensorflow/python/ops/math_grad.py b/tensorflow/python/ops/math_grad.py
index 962d2d091d..52805b174c 100644
--- a/tensorflow/python/ops/math_grad.py
+++ b/tensorflow/python/ops/math_grad.py
@@ -20,10 +20,10 @@ from __future__ import print_function
import numpy as np
+from tensorflow.python.framework import constant_op
from tensorflow.python.framework import dtypes
from tensorflow.python.framework import ops
from tensorflow.python.ops import array_ops
-from tensorflow.python.ops import constant_op
from tensorflow.python.ops import gen_array_ops
from tensorflow.python.ops import math_ops
diff --git a/tensorflow/python/ops/math_ops.py b/tensorflow/python/ops/math_ops.py
index 5f1aa0198b..3860e62fa4 100644
--- a/tensorflow/python/ops/math_ops.py
+++ b/tensorflow/python/ops/math_ops.py
@@ -202,13 +202,13 @@ from __future__ import print_function
import numpy as np
import six.moves
-from tensorflow.python.client import graph_util
+from tensorflow.python.framework import common_shapes
from tensorflow.python.framework import dtypes
+from tensorflow.python.framework import graph_util
from tensorflow.python.framework import ops
from tensorflow.python.framework import tensor_shape
from tensorflow.python.framework import tensor_util
from tensorflow.python.ops import array_ops
-from tensorflow.python.ops import common_shapes
from tensorflow.python.ops import gen_data_flow_ops
from tensorflow.python.ops import gen_math_ops
from tensorflow.python.ops import gen_sparse_ops
@@ -1684,8 +1684,6 @@ def _SparseSegmentReductionShape(op):
@ops.RegisterShape("SparseSegmentMeanGrad")
@ops.RegisterShape("SparseSegmentSqrtNGrad")
-
-
# pylint: disable=invalid-name
def _SparseSegmentReductionGradShape(op):
"""Shape function for the SparseSegment[Mean|SqrtN]Grad ops."""
@@ -1728,7 +1726,7 @@ def reduced_shape(input_shape, axes):
Returns:
A 1-D Tensor, the output shape as if keep_dims were set to True.
"""
- # Example:
+ # Example:
# cast needed for SparseTensor reductions
input_shape = to_int32(input_shape) # [2, 3, 5, 7]
axes = to_int32(axes) # [1, 2]
diff --git a/tensorflow/python/ops/math_ops_test.py b/tensorflow/python/ops/math_ops_test.py
index 5e4155af1a..fdcae795dc 100644
--- a/tensorflow/python/ops/math_ops_test.py
+++ b/tensorflow/python/ops/math_ops_test.py
@@ -20,8 +20,8 @@ from __future__ import print_function
import numpy as np
+from tensorflow.python.framework import constant_op
from tensorflow.python.framework import test_util
-from tensorflow.python.ops import constant_op
from tensorflow.python.ops import math_ops
from tensorflow.python.platform import googletest
diff --git a/tensorflow/python/ops/nn.py b/tensorflow/python/ops/nn.py
index fe381c17c1..a502472371 100644
--- a/tensorflow/python/ops/nn.py
+++ b/tensorflow/python/ops/nn.py
@@ -269,12 +269,12 @@ from __future__ import print_function
from six.moves import xrange # pylint: disable=redefined-builtin
+from tensorflow.python.framework import constant_op
from tensorflow.python.framework import dtypes
from tensorflow.python.framework import ops
from tensorflow.python.framework import tensor_shape
from tensorflow.python.ops import array_ops
from tensorflow.python.ops import candidate_sampling_ops
-from tensorflow.python.ops import constant_op
from tensorflow.python.ops import control_flow_ops
from tensorflow.python.ops import embedding_ops
from tensorflow.python.ops import init_ops
diff --git a/tensorflow/python/ops/nn_ops.py b/tensorflow/python/ops/nn_ops.py
index e1c0085437..d17536daeb 100644
--- a/tensorflow/python/ops/nn_ops.py
+++ b/tensorflow/python/ops/nn_ops.py
@@ -21,13 +21,13 @@ from __future__ import print_function
import numpy as np
-from tensorflow.python.client import graph_util
+from tensorflow.python.framework import common_shapes
from tensorflow.python.framework import dtypes
+from tensorflow.python.framework import graph_util
from tensorflow.python.framework import ops
from tensorflow.python.framework import tensor_shape
from tensorflow.python.framework import tensor_util
from tensorflow.python.ops import array_ops
-from tensorflow.python.ops import common_shapes
from tensorflow.python.ops import gen_nn_ops
from tensorflow.python.ops import math_ops
from tensorflow.python.ops import random_ops
diff --git a/tensorflow/python/ops/parsing_ops.py b/tensorflow/python/ops/parsing_ops.py
index e80dfec310..2a9f44b8bd 100644
--- a/tensorflow/python/ops/parsing_ops.py
+++ b/tensorflow/python/ops/parsing_ops.py
@@ -21,11 +21,11 @@ from __future__ import print_function
import collections
import re
+from tensorflow.python.framework import common_shapes
+from tensorflow.python.framework import constant_op
from tensorflow.python.framework import ops
from tensorflow.python.framework import tensor_shape
from tensorflow.python.ops import array_ops
-from tensorflow.python.ops import common_shapes
-from tensorflow.python.ops import constant_op
from tensorflow.python.ops import control_flow_ops
from tensorflow.python.ops import gen_parsing_ops
from tensorflow.python.ops import logging_ops
diff --git a/tensorflow/python/ops/random_ops.py b/tensorflow/python/ops/random_ops.py
index a16682dab8..05558d6d4e 100644
--- a/tensorflow/python/ops/random_ops.py
+++ b/tensorflow/python/ops/random_ops.py
@@ -19,13 +19,13 @@ from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
+from tensorflow.python.framework import common_shapes
from tensorflow.python.framework import dtypes
from tensorflow.python.framework import ops
from tensorflow.python.framework import tensor_shape
from tensorflow.python.framework import tensor_util
from tensorflow.python.framework import random_seed
from tensorflow.python.ops import array_ops
-from tensorflow.python.ops import common_shapes
from tensorflow.python.ops import control_flow_ops
from tensorflow.python.ops import gen_random_ops
from tensorflow.python.ops import logging_ops
diff --git a/tensorflow/python/ops/script_ops.py b/tensorflow/python/ops/script_ops.py
index 35bf2a1725..7be4fc93d5 100644
--- a/tensorflow/python/ops/script_ops.py
+++ b/tensorflow/python/ops/script_ops.py
@@ -27,8 +27,8 @@ from __future__ import print_function
import numpy as np
from tensorflow.python import pywrap_tensorflow
+from tensorflow.python.framework import common_shapes
from tensorflow.python.framework import ops
-from tensorflow.python.ops import common_shapes
from tensorflow.python.ops import gen_script_ops
diff --git a/tensorflow/python/ops/state_ops.py b/tensorflow/python/ops/state_ops.py
index 726b7137c3..4d2f231b27 100644
--- a/tensorflow/python/ops/state_ops.py
+++ b/tensorflow/python/ops/state_ops.py
@@ -101,10 +101,10 @@ from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
+from tensorflow.python.framework import common_shapes
from tensorflow.python.framework import ops
from tensorflow.python.framework import tensor_shape
from tensorflow.python.framework import tensor_util
-from tensorflow.python.ops import common_shapes
from tensorflow.python.ops import gen_state_ops
# go/tf-wildcard-import
# pylint: disable=wildcard-import
diff --git a/tensorflow/python/ops/string_ops.py b/tensorflow/python/ops/string_ops.py
index d6f813181d..bb1ba6786f 100644
--- a/tensorflow/python/ops/string_ops.py
+++ b/tensorflow/python/ops/string_ops.py
@@ -36,10 +36,10 @@ from __future__ import print_function
import numpy as np
+from tensorflow.python.framework import common_shapes
from tensorflow.python.framework import ops
from tensorflow.python.framework import tensor_shape
from tensorflow.python.framework import tensor_util
-from tensorflow.python.ops import common_shapes
# pylint: disable=unused-import
from tensorflow.python.ops import gen_string_ops
# pylint: enable=unused-import
diff --git a/tensorflow/python/ops/tensor_array_ops.py b/tensorflow/python/ops/tensor_array_ops.py
index 08f71bd8e5..49e932e426 100644
--- a/tensorflow/python/ops/tensor_array_ops.py
+++ b/tensorflow/python/ops/tensor_array_ops.py
@@ -25,12 +25,12 @@ from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
+from tensorflow.python.framework import constant_op
from tensorflow.python.framework import dtypes as _dtypes
from tensorflow.python.framework import ops
from tensorflow.python.framework import tensor_shape
from tensorflow.python.framework import tensor_util
from tensorflow.python.ops import array_ops
-from tensorflow.python.ops import constant_op
from tensorflow.python.ops import gen_data_flow_ops
from tensorflow.python.ops import math_ops
diff --git a/tensorflow/python/tools/freeze_graph.py b/tensorflow/python/tools/freeze_graph.py
index 8dc369bb3d..21e4a84551 100644
--- a/tensorflow/python/tools/freeze_graph.py
+++ b/tensorflow/python/tools/freeze_graph.py
@@ -40,7 +40,7 @@ from __future__ import print_function
import tensorflow as tf
from google.protobuf import text_format
-from tensorflow.python.client import graph_util
+from tensorflow.python.framework import graph_util
FLAGS = tf.app.flags.FLAGS
diff --git a/tensorflow/python/tools/strip_unused.py b/tensorflow/python/tools/strip_unused.py
index 578fefd81d..fd6b456f56 100644
--- a/tensorflow/python/tools/strip_unused.py
+++ b/tensorflow/python/tools/strip_unused.py
@@ -45,7 +45,7 @@ import copy
import tensorflow as tf
from google.protobuf import text_format
-from tensorflow.python.client import graph_util
+from tensorflow.python.framework import graph_util
FLAGS = tf.app.flags.FLAGS
diff --git a/tensorflow/python/training/adadelta.py b/tensorflow/python/training/adadelta.py
index 88ab541bea..50bb28ebcd 100644
--- a/tensorflow/python/training/adadelta.py
+++ b/tensorflow/python/training/adadelta.py
@@ -19,7 +19,6 @@ from __future__ import division
from __future__ import print_function
from tensorflow.python.framework import ops
-from tensorflow.python.ops import constant_op
from tensorflow.python.ops import math_ops
from tensorflow.python.training import optimizer
from tensorflow.python.training import training_ops
diff --git a/tensorflow/python/training/adagrad.py b/tensorflow/python/training/adagrad.py
index a1c8e667f1..9646c5c228 100644
--- a/tensorflow/python/training/adagrad.py
+++ b/tensorflow/python/training/adagrad.py
@@ -18,8 +18,8 @@ from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
+from tensorflow.python.framework import constant_op
from tensorflow.python.framework import ops
-from tensorflow.python.ops import constant_op
from tensorflow.python.ops import math_ops
from tensorflow.python.training import optimizer
from tensorflow.python.training import training_ops
diff --git a/tensorflow/python/training/ftrl.py b/tensorflow/python/training/ftrl.py
index b42d29aa2e..2bb4864d4a 100644
--- a/tensorflow/python/training/ftrl.py
+++ b/tensorflow/python/training/ftrl.py
@@ -18,8 +18,8 @@ from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
+from tensorflow.python.framework import constant_op
from tensorflow.python.framework import ops
-from tensorflow.python.ops import constant_op
from tensorflow.python.ops import math_ops
from tensorflow.python.training import optimizer
from tensorflow.python.training import training_ops
diff --git a/tensorflow/python/training/gradient_descent.py b/tensorflow/python/training/gradient_descent.py
index fb7e514214..3e3f573563 100644
--- a/tensorflow/python/training/gradient_descent.py
+++ b/tensorflow/python/training/gradient_descent.py
@@ -19,7 +19,6 @@ from __future__ import division
from __future__ import print_function
from tensorflow.python.framework import ops
-from tensorflow.python.ops import constant_op
from tensorflow.python.ops import math_ops
from tensorflow.python.training import optimizer
from tensorflow.python.training import training_ops
diff --git a/tensorflow/python/training/input.py b/tensorflow/python/training/input.py
index 3c99a30309..ee8ad9878c 100644
--- a/tensorflow/python/training/input.py
+++ b/tensorflow/python/training/input.py
@@ -27,11 +27,11 @@ import collections
from six.moves import xrange # pylint: disable=redefined-builtin
+from tensorflow.python.framework import constant_op
from tensorflow.python.framework import dtypes
from tensorflow.python.framework import ops
from tensorflow.python.framework import tensor_shape
from tensorflow.python.ops import array_ops
-from tensorflow.python.ops import constant_op
from tensorflow.python.ops import data_flow_ops
from tensorflow.python.ops import io_ops
from tensorflow.python.ops import logging_ops
diff --git a/tensorflow/python/training/momentum.py b/tensorflow/python/training/momentum.py
index 80e3c8bcfb..1586ddfdec 100644
--- a/tensorflow/python/training/momentum.py
+++ b/tensorflow/python/training/momentum.py
@@ -19,7 +19,6 @@ from __future__ import division
from __future__ import print_function
from tensorflow.python.framework import ops
-from tensorflow.python.ops import constant_op
from tensorflow.python.ops import math_ops
from tensorflow.python.training import optimizer
from tensorflow.python.training import training_ops
diff --git a/tensorflow/python/training/proximal_adagrad.py b/tensorflow/python/training/proximal_adagrad.py
index d1bfe70712..c197540d24 100644
--- a/tensorflow/python/training/proximal_adagrad.py
+++ b/tensorflow/python/training/proximal_adagrad.py
@@ -18,8 +18,8 @@ from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
+from tensorflow.python.framework import constant_op
from tensorflow.python.framework import ops
-from tensorflow.python.ops import constant_op
from tensorflow.python.training import optimizer
from tensorflow.python.training import training_ops
diff --git a/tensorflow/python/training/rmsprop.py b/tensorflow/python/training/rmsprop.py
index 5100cedf88..a0019cc8b9 100644
--- a/tensorflow/python/training/rmsprop.py
+++ b/tensorflow/python/training/rmsprop.py
@@ -32,8 +32,8 @@ from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
+from tensorflow.python.framework import constant_op
from tensorflow.python.framework import ops
-from tensorflow.python.ops import constant_op
from tensorflow.python.ops import math_ops
from tensorflow.python.training import optimizer
from tensorflow.python.training import training_ops
diff --git a/tensorflow/python/training/saver.py b/tensorflow/python/training/saver.py
index 2214151a79..2a943b5911 100644
--- a/tensorflow/python/training/saver.py
+++ b/tensorflow/python/training/saver.py
@@ -35,14 +35,14 @@ from tensorflow.core.framework import op_def_pb2
from tensorflow.core.protobuf import meta_graph_pb2
from tensorflow.core.protobuf import saver_pb2
from tensorflow.python import pywrap_tensorflow
-from tensorflow.python.client import graph_util
from tensorflow.python.client import session
+from tensorflow.python.framework import constant_op
from tensorflow.python.framework import device as pydev
+from tensorflow.python.framework import graph_util
from tensorflow.python.framework import importer
from tensorflow.python.framework import op_def_registry
from tensorflow.python.framework import ops
from tensorflow.python.ops import array_ops
-from tensorflow.python.ops import constant_op
from tensorflow.python.ops import control_flow_ops
from tensorflow.python.ops import gen_io_ops
from tensorflow.python.ops import io_ops
diff --git a/tensorflow/python/training/training_ops_test.py b/tensorflow/python/training/training_ops_test.py
index ff24852852..672f33ba82 100644
--- a/tensorflow/python/training/training_ops_test.py
+++ b/tensorflow/python/training/training_ops_test.py
@@ -24,9 +24,9 @@ import itertools
import numpy as np
import tensorflow as tf
+from tensorflow.python.framework import constant_op
from tensorflow.python.framework import dtypes
from tensorflow.python.framework.test_util import TensorFlowTestCase
-from tensorflow.python.ops import constant_op
from tensorflow.python.ops import variables
from tensorflow.python.platform import googletest
from tensorflow.python.training import training_ops