【问题标题】:How to get the currently active tf.variable_scope in TensorFlow?如何在 TensorFlow 中获取当前活动的 tf.variable_scope?
【发布时间】:2016-07-17 14:41:28
【问题描述】:

我编写了一个方便的 API 来在 TensorFlow 中定义我的模型,该模型公开了一个范围对象。现在我想在添加操作之前验证用户是否确实进入了范围。如何获取TensorFlow中当前活跃的tf.variable_scope的名称?

【问题讨论】:

    标签: tensorflow named-scope


    【解决方案1】:

    您可以使用 tf.get_variable_scope() 获取当前活动范围:

    using tensorflow as tf
    with tf.variable_scope("my_scope"):
      print(tf.get_variable_scope().name)
    

    这将打印“my_scope”

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-03-03
      • 1970-01-01
      • 2012-08-20
      • 2014-08-22
      • 2020-06-27
      • 2012-07-09
      • 1970-01-01
      相关资源
      最近更新 更多