TensorFlow - 嵌套变量作用域
问题描述:
的行为,请考虑以下的Python 2段使用TensorFlowTensorFlow - 嵌套变量作用域
with tf.variable_scope('scope'):
layer = slim.conv2d(input_tensor, 64, 7, 2, padding='SAME', scope='another_scope')
我创建一个变量范围内的conv2d
层,但我也通过另一个变量的作用域名称,明确到的构造函数写conv2d
层。
我的问题如下:
- 会有什么变量
layer
的名称,并在其范围将这个变量定义 -scope
或another_scope
。 - 允许用户声明像这样的变量的用例是什么?
- 是否有可能在TensorFlow中创建嵌套变量作用域?如果是,那么它是如何工作的?
- 如果范围
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')