Caffe学习系列(九):网络压缩与剪枝

Caffe学习系列(九):网络压缩与剪枝

Flag

1. 网络压缩

github 搜 Deep compression 结果
在这里插入图片描述

1.1 SqueezeNet-Deep-Compression

https://github.com/songhan/SqueezeNet-Deep-Compression

使用方法:

export CAFFE_ROOT=$your_caffe_root

python decode.py /ABSOLUTE_PATH_TO/SqueezeNet_deploy.prototxt /ABSOLUTE_PATH_TO/compressed_SqueezeNet.net /ABSOLUTE_PATH_TO/decompressed_SqueezeNet.caffemodel

note: decompressed_SqueezeNet.caffemodel is the output, can be any name.

$CAFFE_ROOT/build/tools/caffe test --model=SqueezeNet_trainval.prototxt --weights=decompressed_SqueezeNet.caffemodel --iterations=1000 --gpu 0
1.2 DeepCompression-caffe

https://github.com/may0324/DeepCompression-caffe
内含 Lenet 压缩例程 train_compress_lenet.py

使用方法:

# clone repository and make 
$ git clone https://github.com/may0324/DeepCompression-caffe.git
$ cd DeepCompression-caffe
$ make -j 32 

# run demo script, this will finetune a pretrained model
$ python examples/mnist/train_compress_lenet.py
1.3 其他

网络剪枝:【用Python学习Caffe】7. 网络结构的修剪
github 仓库:Caffe-Python-Tutorial

Caffe for Sparse and Low-rank Deep Neural Networks
EasyDeepCompression

1.4 重要参考

Deep Compression阅读理解及Caffe源码修改

深度学习 模型 剪枝
深度学习模型压缩方法综述(一)

2. 网络剪枝
2.1 网络剪枝

caffemodel的剪枝与压缩(一)
论文:《Pruning Filters for Efficient Convnets》
剪枝分类了解一下《手把手AI项目》十一、深度学习中模型model的剪枝笔记

剪枝类型

  • 稀疏剪枝(这个没有看到具体论文,只看到别的论文中提到,估计太常见了)
  • fiters pruning
  • channel pruning

论文记录-Pruning Filters For Efficient ConvNets
论文品读:Pruning filters for effecient convnets
论文源码

2.2 Caffe-Python-Tutorial

Caffe-Python-Tutorial
目前

目前,已经复现 prune.py 对 Lenet5 的裁剪,对 VGG_SSD 测试存在问题
在这里插入图片描述

2.3 channel-pruning

发生以下报错:

Check failed: fd != -1 (-1 vs. -1) File not found: data/VOC0712/labelmap_voc.prototxt

原因:/caffe-ssd/models/VGGNet/VOC0712/SSD_300x300/deploy.prototxt 路径有问题,改为绝对路径即可

      output_name_prefix: "comp4_det_test_"
      output_format: "VOC"
      label_map_file: "data/VOC0712/labelmap_voc.prototxt"
3. 模型量化

参考项目:
基于Caffe-Int8-Convert-Tools进行caffe模型转int8量化日常记录
《手把手AI项目》十、利用量化工具caffe-int8-convert-tools实现caffemodel量化(double32->int8)
实现原理:
基于tensorRT方案的INT8量化实现

python2 caffe-int8-convert-tool-dev.py --proto=test/models/MobileNetSSD_deploy_new.prototxt --model=test/models/MobileNetSSD_deploy_new.caffemodel --mean 127.5 127.5 127.5 --norm=0.007843 --images=test/images/ --output=test/MobileNetSSD.table 

切换到 caffe-int8-convert-tools/test 目录下

/home/hitwh/workspace/ncnn/build/tools/caffe/caffe2ncnn /home/hitwh/workspace/caffe-int8-convert-tools/test/models/MobileNetSSD_deploy_new.prototxt /home/hitwh/workspace/caffe-int8-convert-tools/test/models/MobileNetSSD_deploy_new.caffemodel MobileNetSSD-int8.param MobileNetSSD-int8.bin 256 MobileNetSSD.table

CNN模型 INT8 量化实现方式(一)
CNN模型 int8量化实现方式(二)

神经网络压缩 剪枝 量化 嵌入式计算优化NCNN mobilenet squeezenet shufflenet

3. 安卓端优化

基于ncnn的深度学习算法优化(一)
深度学习实战教程(1)–手机上跑目标检测模型(YOLO,从DarkNet到Caffe再到NCNN完整打通)
树莓派3B完成ncnn框架测试
神经网络高性能计算 卷积计算优化 openblas GEMM 矩阵乘法优化 ncnn mobileNet-ssd shueezeNet-ssd

  • 2
    点赞
  • 11
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

la_fe_

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值