slim.arg_scope嵌套理解(简单)

def new_arg_sc():

    with slim.arg_scope([slim.conv2d, slim.fully_connected],

                        trainable=True,

                        activation_fn=tf.nn.relu,

                        weights_initializer=tf.truncated_normal_initializer(stddev=0.01),

                        weights_regularizer=slim.l2_regularizer(0.0001)):

        with slim.arg_scope([slim.conv2d],

                            kernel_size=[3, 3],

                            padding='SAME',

                            normalizer_fn=slim.batch_norm) as sc:

            return sc

嵌套第一层 slim.arg_scope 代表设置默认的 slim.conv2dslim.fully_connected 的通用参数

第二层 slim.arg_scope则在原来设置的默认参数基础上设置 slim.conv2d 其他三个 slim.fully_connected没有的参数:

kernel_size、padding、normalizer_fn


返回的 sc 可以作为其他slim.arg_scope的参数进行默认参数的传递:

如:with slim.arg_scope(sc):

 

你可能感兴趣的:(slim.arg_scope嵌套理解(简单))