1、将cpp 和cu文件复制到caffe/src/caffe/layers目录下,将hpp文件复制到caffe/include/caffe/layers/目录下
文件地址:https://github.com/yonghenglh6/DepthwiseConvolution
2、编译caffe
cd caffe_ROOT
make all -j8
3、训练.prototxt中替换相应的层的名字
将group > 1的 Convolution 换成 DepthwiseConvolution
if layer.type == "Convolution":
if layer.convolution_param.group !=1:
layer.type = "DepthwiseConvolution"
4、效果
同样的配置,替换前1个batch平均时间4s,替换后1个batch平均时间0.5。训练时间提升8倍。
参考:https://blog.csdn.net/fengzhongluoleidehua/article/details/80797660