轻量化网络(一)MobileNets: Efficient Convolutional Neural Networks for Mobile Vision Applications
轻量化网络研究(一)MobileNets: Efficient Convolutional Neural Networks for Mobile Vision Applications
研究过深度学习的同学都知道,深度学习对硬件平台要求较高,要玩得动深度学习一般需要一台配备了4块Nvidia 1080Ti的服务器再加上动辄十几个小时的训练时间,让算法在实际应用中几乎不可实现。有很多的应用场景并没有很强的算力,只是普通的移动端或者嵌入式设备,所以如何减少Flops并且提高运行速度值得研究,本文阐述一篇谷歌在2017年发布的轻量化网络MobileNets v1。
MobileNets v1创新点在于使用了深度可分离卷积(depthwise separable filters),通过该卷积大大减少FLOPs,还通过两个超参数(width multiplier and resolution multiplier)调整网络大小和运行速度。
论文链接
Pytorch实现
Tensorflow实现
1、假设
输入特征F大小: D F × D F × M D_{F} \times D_{F} \times M DF×DF×M
输出特征G大小: D F × D F × N D_{F} \times D_{F} \times N DF×DF×N
标准卷积核K大小: D K × D K × M × N D_{K} \times D_{K} \times M\times N DK×DK×M×N
标准卷积的FLOPs: D K × D K × M × D F × D F × N D_{K} \times D_{K} \times M \times D_{F} \times D_{F} \times N DK×DK×M×DF×DF×N
2、深度可分离卷积
深度可分离卷积将标准卷积分为两层卷积: depthwise convolutions和pointwise convolutions。
首先使用depthwise convolutions( D K × D K × 1 × M D_{K} \times D_{K} \times 1 \times M DK×DK×1×M),该卷积核单独卷积输入特征的每一层通道,也就是所谓的组卷积。Pytorch中的操作就是将卷积的group设置为输入特征的channel,即group=M。因为仅对输入特征的每一层通道做了特征提取,组卷积输出的特征没有进行通道之间的信息交互,之后第二步pointwise convolutions。
pointwise convolutions( 1 × 1 × M × N 1 \times 1 \times M \times N 1×1×M×N的卷积核)交互特征之间的信息,pointwise convolutions使用标准的 1 × 1 1 \times 1 1×1卷积核,作用是将特征通道压缩成一层。
depthwise convolutions的FLOPs: D K × D K × M × D F × D F D_{K} \times D_{K} \times M \times D_{F} \times D_{F} DK×DK×M×DF×DF
pointwise convolutions的FLOPs: 1 × 1 × M × D F × D F × N 1 \times1 \times M \times D_{F} \times D_{F} \times N 1×1×M×DF×DF×N
深度可分离卷积的FLOPs: D K × D K × M × D F × D F + M × D F × D F × N D_{K} \times D_{K} \times M \times D_{F} \times D_{F}+ M \times D_{F} \times D_{F} \times N DK×DK×M×DF×DF+M×DF×DF×N
深度可分离卷积和标准卷积FLOPs对比:
D K × D K × M × D F × D F + M × D F × D F × N D K × D K × M × D F × D F × N \frac{D_{K} \times D_{K} \times M \times D_{F} \times D_{F}+ M \times D_{F} \times D_{F} \times N}{D_{K} \times D_{K} \times M \times D_{F} \times D_{F} \times N} DK×DK×M×DF×DF×NDK×DK×M×DF×DF+M×DF×DF×N
= 1 N + 1 D K 2 =\frac{1}{N}+\frac{1}{D_{K}^2} =N1+DK21
从以上结果来看,同样使用 3 × 3 3 \times 3 3×3卷积核的情况下,深度可分离卷积的计算量是标准卷积的 1 8 \frac{1}{8} 81或 1 9 \frac{1}{9} 91。
Figure 3中描述了标准卷积和深度可分离卷积,在深度可分离卷积中每层卷积层后面均有BN层和Relu层。
Table 1中描述了整个Mobilenet v1的网络结构。
#深度可分离卷积的具体实现
def conv_dw(inp, oup, stride):return nn.Sequential(nn.Conv2d(inp, inp, 3, stride, 1, groups=inp, bias=False),nn.BatchNorm2d(inp),nn.ReLU(inplace=True),nn.Conv2d(inp, oup, 1, 1, 0, bias=False),nn.BatchNorm2d(oup),nn.ReLU(inplace=True),)
从Table 2中可以看到 1 × 1 1 \times 1 1×1卷积核的计算量最大。
3、两个超参数:Width Multiplier和Resolution Multiplier
这两个超参数可以控制模型大小,使得模型更小更快,但是同时带来的是模型精度的降低。
Width Multiplier参数 α \alpha α控制特征的通道数,一般 α \alpha α取值为1,0.75,0.5,0.25。
使用该参数之后的FLOPs: D K × D K × α M × D F × D F + α M × D F × D F × α N D_{K} \times D_{K} \times \alpha M \times D_{F} \times D_{F}+ \alpha M \times D_{F} \times D_{F} \times \alpha N DK×DK×αM×DF×DF+αM×DF×DF×αNResolution Multiplier参数 ρ \rho ρ控制特征的分辨率,同样 ρ < 1 \rho<1 ρ<1
使用该参数之后的FLOPs: D K × D K × M × ρ D F × ρ D F + M × ρ D F × ρ D F × α N D_{K} \times D_{K} \times M \times \rho D_{F} \times \rho D_{F}+ M \times \rho D_{F} \times \rho D_{F} \times \alpha N DK×DK×M×ρDF×ρDF+M×ρDF×ρDF×αN,计算量变为原来的 1 ρ 2 \frac{1}{\rho^2} ρ21
MobileNets v1在object detection, finegrain classification, face attributes and large scale geo-localization等领域进行了测试,具体结果参考论文。
轻量化网络(一)MobileNets: Efficient Convolutional Neural Networks for Mobile Vision Applications相关推荐
- MobileNetV1《MobileNets: Efficient Convolutional Neural Networks for Mobile Vision Applications》
MobileNetV1<MobileNets: Efficient Convolutional Neural Networks for Mobile Vision Applications> ...
- 手机CNN网络模型--MobileNets: Efficient Convolutional Neural Networks for Mobile Vision Applications
MobileNets: Efficient Convolutional Neural Networks for Mobile Vision Applications https://arxiv.org ...
- MobileNets: Efficient Convolutional Neural Networks for Mobile Vision Applications
具体实现代码见:https://github.com/marvis/pytorch-mobilenet class Net(nn.Module):def __init__(self):super(Ne ...
- 网络结构(1)ShuffleNet: An Extremely Efficient Convolutional Neural Network for Mobile Devices
论文目录 ShuffleNet: An Extremely Efficient Convolutional Neural Network for Mobile Devices 引言 相关工作 高效模型设计 ...
- 量化网络训练--Towards Effective Low-bitwidth Convolutional Neural Networks
Towards Effective Low-bitwidth Convolutional Neural Networks CVPR2018 https://github.com/nowgood/Qua ...
- 轻量化网络(五)ShuffleNet: An Extremely Efficient Convolutional Neural Network for Mobile Devices
ShuffleNet是由旷视推出的专门为移动设备设计的神经网络,主要使用了pointwise group convolution and channel shuffle这两个操作.实验在Arm端手机上运行 ...
- ShuffleNet: An Extremely Efficient Convolutional Neural Network for Mobile Devices
Abstract 我们介绍了一种名为ShuffleNet的极其计算高效的CNN架构,该架构专为计算能力非常有限的移动设备而设计.新架构采用了两种新的操作,逐点组卷积和通道切换,大大降低了计算成本,同时 ...
- 论文记录_MobileNets Efficient Convolutional Neural Networks for Mobile Vision Application
版权声明:本文为博主原创文章,未经博主允许不得转载. https://blog.csdn.net/u013082989/article/details/77970196 本文个人博客地址:点击查 ...
- 轻量化网络:MobileNets
MobileNets: Efficient Convolutional Neural Networks for Mobile Vision Applications(MobileNets paper) ...
最新文章
- layui 自定义排序_浅谈layui中table的sort排序
- OpenGL画矩形,三角形,点(第一个图形学的小程序)
- php pg connect,pg_connect
- Redis 分布式方案
- HDU 3530 Subsequence
- 论文浅尝 | 用于低资源条件下知识图谱补全的关系对抗网络
- ajax返回html页面执行,【提问】ajax请求返回整个html页面
- python课程设计
- Linux下开启关闭查看软件包信息
- synchronized锁升级之偏向锁
- matlab简单函数画图例题,Matlab(十) 简单的函数画图
- sybase数据库与oracle,Oracle访问Sybase数据库的方法
- 明星分分合合的洪荒点击量,微博Mesh服务化改造如何支撑?(附PPT下载)
- 空间直线与球面的相交算法
- 用PHP实现小写金额转换大写金额【精确到分】
- Verilog 练习 简单状态机代码设计(三角波发生器)
- 1214_嵌入式硬件常识积累_什么是TTL电平
- Spring的装配方式
- 在安装office2003时,出现安装程序包的语言不受系统支持的错误,如何解决?
- vue前端开发微信支付和支付宝支付