What does arg_scope actually do?

I am new to neural networks and TensorFlow, and I am trying to understand the role arg_scope.

It seems to me that this is a way to combine the dictionary of “things you want to do” with a specific layer with certain variables. Please correct me if I am wrong. How would you explain what this is, newbie?

+6
source share
1 answer

When defining convolution levels, you can always use the same fill type and the same initializer, and possibly even the same convolution size. You may be using the same pool size 2x2. Etc.

arg_scope - , .

:

tf.contrib.framework.arg_scope:

from third_party.tensorflow.contrib.layers.python import layers
  arg_scope = tf.contrib.framework.arg_scope
  with arg_scope([layers.conv2d], padding='SAME',
                 initializer=layers.variance_scaling_initializer(),
                 regularizer=layers.l2_regularizer(0.05)):
    net = layers.conv2d(inputs, 64, [11, 11], 4, padding='VALID', scope='conv1')
    net = layers.conv2d(net, 256, [5, 5], scope='conv2')

conv2d :

   layers.conv2d(inputs, 64, [11, 11], 4, padding='VALID',
                  initializer=layers.variance_scaling_initializer(),
                  regularizer=layers.l2_regularizer(0.05), scope='conv1')

conv2d arg_scope :

  layers.conv2d(inputs, 256, [5, 5], padding='SAME',
                  initializer=layers.variance_scaling_initializer(),
                  regularizer=layers.l2_regularizer(0.05), scope='conv2')

arg_scope:

with arg_scope([layers.conv2d], padding='SAME',
                 initializer=layers.variance_scaling_initializer(),
                 regularizer=layers.l2_regularizer(0.05)) as sc:
    net = layers.conv2d(net, 256, [5, 5], scope='conv1')
    ....
  with arg_scope(sc):
    net = layers.conv2d(net, 256, [5, 5], scope='conv2')
+6

All Articles