定義 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。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。