Pocketflow 使用

Pocketflow的简介:https://pocketflow.github.io/

由两个modules组成:Learner module 负责利用随机hyperparameters压缩并fine-tuning,optimizer module 负责依据随机参数对应的结果确定最佳的压缩参数。Learn module 遍历的hyperparameter来自于:

NameDescription
ChannelPrunedLearnerchannel pruning with LASSO-based channel selection (He et al., 2017)
DisChnPrunedLearnerdiscrimination-aware channel pruning (Zhuang et al., 2018)
WeightSparseLearnerweight sparsification with dynamic pruning schedule (Zhu & Gupta, 2017)
UniformQuantLearnerweight quantization with uniform reconstruction levels (Jacob et al., 2018)
UniformQuantTFLearnerweight quantization with uniform reconstruction levels and TensorFlow APIs
NonUniformQuantLearnerweight quantization with non-uniform reconstruction levels (Han et al., 2016)

压缩后可以快速训练收敛。

optimizer module 的策略来自于

Gaussian Processes (GP, Mockus, 1975), Tree-structured Parzen Estimator (TPE, Bergstra et al., 2013), and Deterministic Deep Policy Gradients (DDPG, Lillicrap et al., 2016) 以及当前hyperparameters的reward

安装Pocketflow:https://pocketflow.github.io/installation/

本地安装或在docker环境中安装

本地安装:

配置文件 path.conf 说明数据集路径(.tfrecord)以及预训练模型的路径

首先安装 anaconda 和 tensorflow,注意python 版本不能高于3.6

一句话就可训练:./scripts/run_local.sh nets/resnet_at_cifar10_run.py

docker环境安装:

官方推荐  horovod docker ,因其支持多GPU分布

一句话训练:./scripts/run_docker.sh nets/resnet_at_cifar10_run.py

 

压缩方法:

参考https://pocketflow.github.io/tutorial/

输出:*.tflite 文件

Step 1: 准备数据成TFRecord格式

Step 2: 根据上面的步骤训练或直接下载 .ckpt 模型 保存在 models

Step 3: 选择压缩方法 开始调优压缩后的模型 

./scripts/run_local.sh nets/resnet_at_ilsvrc12_run.py \ --learner dis-chn-pruned

压缩方法与arg对应:

Learner nameLearner classNote
full-precFullPrecLearnerNo model compression
channelChannelPrunedLearnerChannel pruning with LASSO-based channel selection (He et al., 2017)
dis-chn-prunedDisChnPrunedLearnerDiscrimination-aware channel pruning (Zhuang et al., 2018)
weight-sparseWeightSparseLearnerWeight sparsification with dynamic pruning schedule (Zhu & Gupta, 2017)
uniformUniformQuantLearnerWeight quantization with uniform reconstruction levels (Jacob et al., 2018)
uniform-tfUniformQuantTFLearnerWeight quantization with uniform reconstruction levels and TensorFlow APIs
non-uniformNonUniformQuantLearnerWeight quantization with non-uniform reconstruction levels (Han et al., 2016)

保存在models_dcp_eval文件夹

Step 3: 转化成 tflite 格式:

python tools/conversion/export_pb_tflite_models.py \ --model_dir models_dcp_eval

保存在 models_dcp_eval

 

 

 

评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值