tf.get_current_name_scope
Возвращает текущий полный префикс имени области, указанный tf.name_scope(...).
tf.get_current_name_scope()
Например,
with tf.name_scope("outer"):
tf.get_current_name_scope() # "outer"
with tf.name_scope("inner"):
tf.get_current_name_scope() # "outer/inner"
Другими словами, tf.get_current_name_scope() возвращает префикс имени операции, который будет добавлен впереди, если операция создаётся в этом месте.
Обратите внимание, что @tf.function сбрасывает стек области имён, как показано ниже.
with tf.name_scope("outer"):
@tf.function
def foo(x):
with tf.name_scope("inner"):
return tf.add(x * x) # Op name is "inner/Add", not "outer/inner/Add"
© 2022 The TensorFlow Authors. All rights reserved.
Licensed under the Creative Commons Attribution License 4.0.
Code samples licensed under the Apache 2.0 License.
https://www.tensorflow.org/versions/r2.9/api_docs/python/tf/get_current_name_scope