定义 Python 操作时使用的上下文管理器。
用法
tf.compat.v1.keras.backend.name_scope(
name, default_name=None, values=None
)
参数
-
name
传递给 op 函数的名称参数。 -
default_name
如果name
参数是None
,则使用的默认名称。 -
values
传递给 op 函数的Tensor
参数列表。
抛出
-
TypeError
如果default_name
传入但不是字符串。
属性
-
name
此上下文管理器验证给定的values
是否来自同一个图,使该图成为默认图,并在该图中推送一个名称范围(有关详细信息,请参阅tf.Graph.name_scope
)。
例如,要定义一个名为 my_op
的新 Python 操作:
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)
相关用法
- Python tf.compat.v1.keras.initializers.Ones.from_config用法及代码示例
- Python tf.compat.v1.keras.layers.DenseFeatures用法及代码示例
- Python tf.compat.v1.keras.initializers.Zeros.from_config用法及代码示例
- Python tf.compat.v1.keras.utils.track_tf1_style_variables用法及代码示例
- Python tf.compat.v1.keras.initializers.Ones用法及代码示例
- Python tf.compat.v1.keras.initializers.RandomNormal.from_config用法及代码示例
- Python tf.compat.v1.keras.initializers.glorot_uniform.from_config用法及代码示例
- Python tf.compat.v1.keras.initializers.lecun_uniform用法及代码示例
- Python tf.compat.v1.keras.initializers.he_normal.from_config用法及代码示例
- Python tf.compat.v1.keras.initializers.Orthogonal.from_config用法及代码示例
- Python tf.compat.v1.keras.initializers.lecun_normal.from_config用法及代码示例
- Python tf.compat.v1.keras.initializers.TruncatedNormal用法及代码示例
- Python tf.compat.v1.keras.initializers.RandomNormal用法及代码示例
- Python tf.compat.v1.keras.layers.enable_v2_dtype_behavior用法及代码示例
- Python tf.compat.v1.keras.initializers.he_uniform用法及代码示例
- Python tf.compat.v1.keras.initializers.Identity.from_config用法及代码示例
- Python tf.compat.v1.keras.experimental.export_saved_model用法及代码示例
- Python tf.compat.v1.keras.callbacks.TensorBoard用法及代码示例
- Python tf.compat.v1.keras.initializers.Constant用法及代码示例
- Python tf.compat.v1.keras.initializers.Constant.from_config用法及代码示例
注:本文由纯净天空筛选整理自tensorflow.org大神的英文原创作品 tf.compat.v1.keras.backend.name_scope。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。