tf.name_scope
tf.name_scope
tf.contrib.keras.backend.name_scope
tf.name_scope
name_scope( name, default_name=None, values=None )
Defined in tensorflow/python/framework/ops.py
.
See the guide: Building Graphs > Utility functions
Returns a context manager for use when defining a Python op.
This context manager validates that the given values
are from the same graph, makes that graph the default graph, and pushes a name scope in that graph (see tf.Graph.name_scope
for more details on that).
For example, to define a new Python op called my_op
:
def my_op(a, b, c, name=None): with tf.name_scope(name, "MyOp", [a, b, c]) as scope: a = tf.convert_to_tensor(a, name="a") b = tf.convert_to_tensor(b, name="b") c = tf.convert_to_tensor(c, name="c") # Define some computation that uses `a`, `b`, and `c`. return foo_op(..., name=scope)
Args:
-
name
: The name argument that is passed to the op function. -
default_name
: The default name to use if thename
argument isNone
. -
values
: The list ofTensor
arguments that are passed to the op function.
Returns:
A context manager for use in defining Python ops. Yields the name scope.
Raises:
-
ValueError
: if neithername
nordefault_name
is provided butvalues
are.
© 2017 The TensorFlow Authors. All rights reserved.
Licensed under the Creative Commons Attribution License 3.0.
Code samples licensed under the Apache 2.0 License.
https://www.tensorflow.org/api_docs/python/tf/name_scope