ACNet: Strengthening the Kernel Skeletons for Powerful CNN via Asymmetric Convolution Blocks
PDF: https://arxiv.org/pdf/1908.03930v1.pdf
PyTorch代码: https://github.com/shanglianlm0525/PyTorch-Networks

3x3卷积+1x3卷积+3x1卷积==性能提升但是没有额外的推理开销.

class ACBlock(nn.Module):def __init__(self, in_channels, out_channels, kernel_size, stride=1, padding=0, dilation=1, groups=1, padding_mode='zeros', deploy=False):super(ACBlock, self).__init__()self.deploy = deployif deploy:self.fused_conv = nn.Conv2d(in_channels=in_channels, out_channels=out_channels, kernel_size=(kernel_size,kernel_size), stride=stride,padding=padding, dilation=dilation, groups=groups, bias=True, padding_mode=padding_mode)else:self.square_conv = nn.Conv2d(in_channels=in_channels, out_channels=out_channels,kernel_size=(kernel_size, kernel_size), stride=stride,padding=padding, dilation=dilation, groups=groups, bias=False,padding_mode=padding_mode)self.square_bn = nn.BatchNorm2d(num_features=out_channels)self.ver_conv = nn.Conv2d(in_channels=in_channels, out_channels=out_channels, kernel_size=(3, 1),stride=stride,padding=(padding - kernel_size // 2 + 1, padding - kernel_size // 2), dilation=dilation, groups=groups, bias=False,padding_mode=padding_mode)self.ver_bn = nn.BatchNorm2d(num_features=out_channels)self.hor_conv = nn.Conv2d(in_channels=in_channels, out_channels=out_channels, kernel_size=(1, 3),stride=stride,padding=(padding - kernel_size // 2, padding - kernel_size // 2 + 1), dilation=dilation, groups=groups, bias=False,padding_mode=padding_mode)self.hor_bn = nn.BatchNorm2d(num_features=out_channels)def forward(self, input):if self.deploy:return self.fused_conv(input)else:square_outputs = self.square_conv(input)square_outputs = self.square_bn(square_outputs)vertical_outputs = self.ver_conv(input)vertical_outputs = self.ver_bn(vertical_outputs)horizontal_outputs = self.hor_conv(input)horizontal_outputs = self.hor_bn(horizontal_outputs)return square_outputs + vertical_outputs + horizontal_outputs

具体来说就是,训练的时候并行地做3x3, 1x3和3x1卷积,然后将三路的输出加起来, 但是推理的时候将三者转换为一个新的卷积核, 如下图

推断的时候,先BN fusion后Branch fusion,

QUARE_KERNEL_KEYWORD = 'square_conv.weight'def _fuse_kernel(kernel, gamma, std):b_gamma = np.reshape(gamma, (kernel.shape[0], 1, 1, 1))b_gamma = np.tile(b_gamma, (1, kernel.shape[1], kernel.shape[2], kernel.shape[3]))b_std = np.reshape(std, (kernel.shape[0], 1, 1, 1))b_std = np.tile(b_std, (1, kernel.shape[1], kernel.shape[2], kernel.shape[3]))return kernel * b_gamma / b_stddef _add_to_square_kernel(square_kernel, asym_kernel):asym_h = asym_kernel.shape[2]asym_w = asym_kernel.shape[3]square_h = square_kernel.shape[2]square_w = square_kernel.shape[3]square_kernel[:, :, square_h // 2 - asym_h // 2: square_h // 2 - asym_h // 2 + asym_h,square_w // 2 - asym_w // 2 : square_w // 2 - asym_w // 2 + asym_w] += asym_kerneldef convert_acnet_weights(train_weights, deploy_weights, eps):train_dict = read_hdf5(train_weights)print(train_dict.keys())deploy_dict = {}square_conv_var_names = [name for name in train_dict.keys() if SQUARE_KERNEL_KEYWORD in name]for square_name in square_conv_var_names:square_kernel = train_dict[square_name]square_mean = train_dict[square_name.replace(SQUARE_KERNEL_KEYWORD, 'square_bn.running_mean')]square_std = np.sqrt(train_dict[square_name.replace(SQUARE_KERNEL_KEYWORD, 'square_bn.running_var')] + eps)square_gamma = train_dict[square_name.replace(SQUARE_KERNEL_KEYWORD, 'square_bn.weight')]square_beta = train_dict[square_name.replace(SQUARE_KERNEL_KEYWORD, 'square_bn.bias')]ver_kernel = train_dict[square_name.replace(SQUARE_KERNEL_KEYWORD, 'ver_conv.weight')]ver_mean = train_dict[square_name.replace(SQUARE_KERNEL_KEYWORD, 'ver_bn.running_mean')]ver_std = np.sqrt(train_dict[square_name.replace(SQUARE_KERNEL_KEYWORD, 'ver_bn.running_var')] + eps)ver_gamma = train_dict[square_name.replace(SQUARE_KERNEL_KEYWORD, 'ver_bn.weight')]ver_beta = train_dict[square_name.replace(SQUARE_KERNEL_KEYWORD, 'ver_bn.bias')]hor_kernel = train_dict[square_name.replace(SQUARE_KERNEL_KEYWORD, 'hor_conv.weight')]hor_mean = train_dict[square_name.replace(SQUARE_KERNEL_KEYWORD, 'hor_bn.running_mean')]hor_std = np.sqrt(train_dict[square_name.replace(SQUARE_KERNEL_KEYWORD, 'hor_bn.running_var')] + eps)hor_gamma = train_dict[square_name.replace(SQUARE_KERNEL_KEYWORD, 'hor_bn.weight')]hor_beta = train_dict[square_name.replace(SQUARE_KERNEL_KEYWORD, 'hor_bn.bias')]fused_bias = square_beta + ver_beta + hor_beta - square_mean * square_gamma / square_std \- ver_mean * ver_gamma / ver_std - hor_mean * hor_gamma / hor_stdfused_kernel = _fuse_kernel(square_kernel, square_gamma, square_std)_add_to_square_kernel(fused_kernel, _fuse_kernel(ver_kernel, ver_gamma, ver_std))_add_to_square_kernel(fused_kernel, _fuse_kernel(hor_kernel, hor_gamma, hor_std))deploy_dict[square_name.replace(SQUARE_KERNEL_KEYWORD, 'fused_conv.weight')] = fused_kerneldeploy_dict[square_name.replace(SQUARE_KERNEL_KEYWORD, 'fused_conv.bias')] = fused_biasfor k, v in train_dict.items():if 'hor_' not in k and 'ver_' not in k and 'square_' not in k:deploy_dict[k] = vsave_hdf5(deploy_dict, deploy_weights)

轻量级网络论文: ACNet: Strengthening the Kernel Skeletons for Powerful CNN via Asymmetric Convolution Block相关推荐

  1. 论文阅读 ACNet: Strengthening the Kernel Skeletons for Powerful CNN via Asymmetric Convolution Blocks

    论文阅读 ACNet: Strengthening the Kernel Skeletons for Powerful CNN via Asymmetric Convolution Blocks 前言 ...

  2. 『论文笔记』ACNet: Strengthening the Kernel Skeletons for Powerful CNN via Asymmetric Convolution Blocks!

    ACNet: Strengthening the Kernel Skeletons for Powerful CNN via Asymmetric Convolution Blocks! 文章目录 一 ...

  3. 论文阅读——ACNet:Strengthening the Kernel Skeletons for Powerful CNN via Asymmetric Convolution Blocks

    ACNet:Strengthening the Kernel Skeletons for Powerful CNN via Asymmetric Convolution Blocks ACNet:通过 ...

  4. 转载系列 |ICCV2019:ACNet:Strengthening the Kernel Skeletons for Powerful CNN via Asymmetric Convolution

    论文:ACNet: Strengthening the Kernel Skeletons for Powerful CNN via Asymmetric Convolution Blocks 论文链接 ...

  5. ACNet: Strengthening the Kernel Skeletons for Powerful CNN via Asymmetric Convolution Blocks

    paper:http://xxx.itp.ac.cn/pdf/1908.03930.pdf code:mirrors / DingXiaoH / acnet · GitCode 摘要: 提出了非对称卷 ...

  6. 【MLDL】【skimming】ACNet: Strengthening the Kernel Skeletons for Powerful CNN

    略读2019 ICCV的ACNet: Strengthening the Kernel Skeletons for Powerful CNN via Asymmetric Convolution Bl ...

  7. rep论文阅读1:ACNet_Strengthening the Kernel Skeletons for Powerful CNN via Asymmetric Convolution Blocks

    ACNet:通过非对称卷积模块增强CNN的卷积核骨架 paper:https://arxiv.org/abs/1908.03930 code:https://github.com/DingXiaoH/ ...

  8. 轻量级网络论文精度笔记(三):《Searching for MobileNetV3》

    MobileNetV3 论文链接 论文名字 参考文献 1. 研究背景 2. 创新贡献 3. 相关工作 3.1 高效移动端构建块 4. 网格搜索 5. 网络的改进 5.1 重新设计计算复杂层 5.2 设 ...

  9. 【ICCV-2019】ACNet:通过非对称卷积块增强CNN的核骨架 3*3卷积==>1*3卷积+3*1卷积=白给的精度提升

    论文:https://arxiv.org/pdf/1908.03930v1.pdf 代码:https://github.com/ShawnDing1994/ACN 通过非对称卷积块增强CNN的核骨架 ...

最新文章

  1. java闭合数据_java多线程中线程封闭详解
  2. 【 MATLAB 】使用 MATLAB 得到高密度谱(补零得到DFT)和高分辨率谱(获得更多的数据得到DFT)的方式对比(附MATLAB脚本)
  3. 数学建模太难?做到这三件事,让你事半功倍
  4. 【转】Apache Solr 访问权限控制
  5. 微信小程序DAU超4.5亿 小程序开发者突破300万
  6. 凝思系统如何调节分辨率_如何消除步进电机的噪音和振动?
  7. HDU 6166 2017 多校训练:Senior Pan(最短路)
  8. 鼠标不受控制一直向右移动的解决办法
  9. java大牛博客链接合集
  10. 无人车系统(三):用python写一个简单的无人车仿真环境
  11. 计算机教室的英文音标,小学四年级英语单词(带音标).doc
  12. 魔兽插件是用php吗,GitHub - robinmo/wow_addons_private_use: World Of Warcraft Addons private use 魔兽世界自用插件...
  13. html5 css3学习资料、教程、实例收集
  14. 腾讯云运维干货沙龙-海量运维实践大曝光 (一)
  15. 问题 A: Jugs
  16. 仿京东轮播的广告展示栏
  17. 怎么解决word中英文混合换行后字体间隔变大问题
  18. python制作辅助和易语言的区别_为什么多数外挂都用易语言?
  19. QGIS-创建QGIS项目
  20. ‘python不是内部或外部命令’解决办法

热门文章

  1. 2014深圳锐明视讯校园招聘 [李园7舍_404]
  2. T027基于51单片机的智能窗帘窗户控制系统proteus仿真原理图PCB
  3. 智慧停车场行业室外停车场实用价值
  4. 【工业大数据】 昆仑数据首席科学家田春华:人工智能降低了工业大数据分析的门槛
  5. python 动态执行 内存变化_详解Pytorch显存动态分配规律探索
  6. 记一次ORA-24247: network access denied by access control list (ACL)
  7. OCR技术简介——人工智能爆发前的技术
  8. 【经验分享】我的数据挖掘竞赛之路及秋招总结
  9. u盘启动linux只有光标闪烁,deepin官方论坛-深度科技官网旗下网站
  10. Visual Studio 2015 - 桌面添加快捷方式