What is the name of variable which is declared in a nested variable scope?

Viewed 1393

Consider the following Python 2 snippet written using TensorFlow

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

I am creating a conv2d layer within a variable scope but am also passing another variable scope name explicitly to the constructor of the conv2d layer.

My questions are as follows:

  1. What will be the name of the variable layer and in which scope would this variable be defined - scope or another_scope.
  2. What is the use case for allowing users to declare variables like this?
  3. Is it possible to create nested variable scopes in TensorFlow? If yes, then how does it work?
  4. If scope another_scope hasn't been created itself, would TensorFlow create this on its own?
1 Answers

So it turns out that the variable layer will have its full scope as scope/another_scope. To me, it seems that they have provided the scope argument so that it serves as a shorthand to doing

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