TensorFlow - 嵌套变量作用域

问题描述:

的行为,请考虑以下的Python 2段使用TensorFlowTensorFlow - 嵌套变量作用域

with tf.variable_scope('scope'): 
    layer = slim.conv2d(input_tensor, 64, 7, 2, padding='SAME', scope='another_scope') 

我创建一个变量范围内的conv2d层,但我也通过另一个变量的作用域名称,明确到的构造函数写conv2d层。

我的问题如下:

  1. 会有什么变量layer的名称,并在其范围将这个变量定义 - scopeanother_scope
  2. 允许用户声明像这样的变量的用例是什么?
  3. 是否有可能在TensorFlow中创建嵌套变量作用域?如果是,那么它是如何工作的?
  4. 如果范围another_scope尚未自行创建,TensorFlow会自行创建它吗?

谢谢!

因此,事实证明变量layer将具有作为scope/another_scope的完整范围。对我来说,似乎他们已经提供了范围论据,以便它可以作为一个简写来做

with tf.variable_scope('scope'): 
    with tf.variable_scope('another_scope'): 
     layer = slim.conv2d(input_tensor, 64, 7, 2, padding='SAME')