qq_33837208
2018-08-07 08:14
采纳率: 25%
浏览 4.9k
已采纳

基于Keras的YOLOV3源码实现疑问

 @wraps(Conv2D)
def DarknetConv2D(*args, **kwargs):
    """Wrapper to set Darknet parameters for Convolution2D."""
    darknet_conv_kwargs = {'kernel_regularizer': l2(5e-4)}
    darknet_conv_kwargs['padding'] = 'valid' if kwargs.get('strides')==(2,2) else 'same'
    darknet_conv_kwargs.update(kwargs)
    return Conv2D(*args, **darknet_conv_kwargs)

def DarknetConv2D_BN_Leaky(*args, **kwargs):#*用于参数前面,表示传入的(多个)参数将按照元组的形式存储;**用于参数前则表示传入的(多个)参数将按照字典的形式存储
    """Darknet Convolution2D followed by BatchNormalization and LeakyReLU."""
    no_bias_kwargs = {'use_bias': False}
    no_bias_kwargs.update(kwargs)
    return compose(
        DarknetConv2D(*args, **no_bias_kwargs),
        BatchNormalization(),#归一化
        LeakyReLU(alpha=0.1))#compose函数的作用:为嵌套函数  a = compose(b,c,d)   则a(1)=d(c(b(1)))

def resblock_body(x, num_filters, num_blocks):
    '''A series of resblocks starting with a downsampling Convolution2D'''
    # Darknet uses left and top padding instead of 'same' mode
    x = ZeroPadding2D(((1,0),(1,0)))(x)#???
    x = DarknetConv2D_BN_Leaky(num_filters, (3,3), strides=(2,2))(x)
    for i in range(num_blocks):
        y = compose(
                DarknetConv2D_BN_Leaky(num_filters//2, (1,1)),
                DarknetConv2D_BN_Leaky(num_filters, (3,3)))(x)
        x = Add()([x,y])
    return x
    1.请问这里wraps的功能以及意义是什么?
    2.源码中出现大量类似x = ZeroPadding2D(((1,0),(1,0)))(x)#???形式的语句,请问语句最后的(x)是什么意思?
    3. x = DarknetConv2D_BN_Leaky(num_filters, (3,3), strides=(2,2))(x)语句在调用DarknetConv2D_BN_Leaky函数时传入的参数哪一部分是*args,哪一步分是 **kwargs
  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

1条回答 默认 最新

相关推荐 更多相似问题