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):

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章