【发布时间】:2016-07-17 14:41:28
【问题描述】:
我编写了一个方便的 API 来在 TensorFlow 中定义我的模型,该模型公开了一个范围对象。现在我想在添加操作之前验证用户是否确实进入了范围。如何获取TensorFlow中当前活跃的tf.variable_scope的名称?
【问题讨论】:
我编写了一个方便的 API 来在 TensorFlow 中定义我的模型,该模型公开了一个范围对象。现在我想在添加操作之前验证用户是否确实进入了范围。如何获取TensorFlow中当前活跃的tf.variable_scope的名称?
【问题讨论】:
您可以使用 tf.get_variable_scope() 获取当前活动范围:
using tensorflow as tf
with tf.variable_scope("my_scope"):
print(tf.get_variable_scope().name)
这将打印“my_scope”
【讨论】: