mobile net 的 depthwise conv 和 origin conv 的对比
Posted 血影雪梦
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了mobile net 的 depthwise conv 和 origin conv 的对比相关的知识,希望对你有一定的参考价值。
在inputchannel = k,outputchannel = q的情况下。
Mobilenet conv将 origin conv拆成了depthwise conv+pointwise conv,如下:
Mobilenet conv:
depthwiseconv filter shape:[di,dj, k, channel_multiplier],channel_multiplier默认=1
pointwiseconv filter shape:[1,1, k*channel_multiplier, q]
因为pointwise conv就是origin conv,所以下面只对比depthwise conv和origin conv。
关于output channel数:
origin conv :
output channel = q(output channel数)
depthwise conv :
output channel = k(input channel数)
PS:实际上outputchannel = k*channel_multiplier,但channel_multiplier默认=1
详情: origin conv: outout: [b, i, j, q] depthwise conv: for _k in 0..(k-1): for _q in 0..(channel_multiplier-1): outout: [b, i, j, _k*channel_multiplier + _q] 因channel_multiplier默认= 1,所以可以写成:outout: [b, i, j, k] |
关于算法实现:
origin conv output channel 的每一层是:
in_channel_0*filter_0 + in_channel_1*filter_1+ ... + in_channel_k*filter_k
depthwise conv output channel 的每一层是:
in_channel_i*filter_0
PS:实际上是:
for i in0..(in_channel-1):
forj in 0..(channel_multiplier-1):
in_channel_i*filter_j
因为channel_multiplier默认为=1,所以可以写成:in_channel_i*filter_0
详情: origin conv: output[b,i,j,0] = sum_di,dj,k input[b, strides[1]*i + di, strides[2] * j + dj,k] * filter[di, dj,k, 0] output[b,i,j,1] = sum_di,dj,k input[b, strides[1]*i + di, strides[2] * j + dj,k] * filter[di, dj,k, 1] ...... output[b,i,j,q] = sum_di,dj,k input[b, strides[1]*i + di, strides[2] * j + dj,k] * filter[di, dj,k, q]
depthwise conv: output[b,i,j, 0] = sum_di, dj input[b, strides[1] * i + di, strides[2] * j + dj,0] * filter[di, dj,0, 0] output[b,i,j, 1] = sum_di, dj input[b, strides[1] * i + di, strides[2] * j + dj,1] * filter[di, dj,1, 0] ...... output[b,i, j, k] = sum_di, dj input[b, strides[1] * i + di, strides[2] * j + dj,k] * filter[di, dj,k, 0] PS:实际上是 for _k in 0..(k-1): for _q in 0..(channel_multiplier-1): output[b, i, j, _k*channel_multiplier+_q] = sum_di, dj input[b, strides[1] * i + di, strides[2] * j + dj, _k] * filter[di, dj, _k, _q] 因为 depthwise conv 的 filter 的 q 默认为 1,所以可以写成上面的形式
|
最后
结合上面这些,论文中的这张图应该就很明了了:
以上是关于mobile net 的 depthwise conv 和 origin conv 的对比的主要内容,如果未能解决你的问题,请参考以下文章
mobile net 的 depthwise conv 和 origin conv 的对比
深度学习方法:卷积神经网络结构变化——Google Inception V1-V4,Xception(depthwise convolution)
深度学习Group Convolution分组卷积Depthwise Convolution和Global Depthwise Convolution
深度学习Group Convolution分组卷积Depthwise Convolution和Global Depthwise Convolution
深度学习面试题24:在每个深度上分别卷积(depthwise卷积)
“object_detection.protos.SsdFeatureExtractor”没有名为“use_depthwise”的字段