Pocketflow 使用
Pocketflow的簡介:https://pocketflow.github.io/
由兩個modules組成:Learner module 負責利用隨機hyperparameters壓縮并fine-tuning,optimizer module 負責依據隨機參數對應的結果確定最佳的壓縮參數。Learn module 遍歷的hyperparameter來自于:
| ChannelPrunedLearner | channel pruning with LASSO-based channel selection (He et al., 2017) |
| DisChnPrunedLearner | discrimination-aware channel pruning (Zhuang et al., 2018) |
| WeightSparseLearner | weight sparsification with dynamic pruning schedule (Zhu & Gupta, 2017) |
| UniformQuantLearner | weight quantization with uniform reconstruction levels (Jacob et al., 2018) |
| UniformQuantTFLearner | weight quantization with uniform reconstruction levels and TensorFlow APIs |
| NonUniformQuantLearner | weight 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對應:
| full-prec | FullPrecLearner | No model compression |
| channel | ChannelPrunedLearner | Channel pruning with LASSO-based channel selection (He et al., 2017) |
| dis-chn-pruned | DisChnPrunedLearner | Discrimination-aware channel pruning (Zhuang et al., 2018) |
| weight-sparse | WeightSparseLearner | Weight sparsification with dynamic pruning schedule (Zhu & Gupta, 2017) |
| uniform | UniformQuantLearner | Weight quantization with uniform reconstruction levels (Jacob et al., 2018) |
| uniform-tf | UniformQuantTFLearner | Weight quantization with uniform reconstruction levels and TensorFlow APIs |
| non-uniform | NonUniformQuantLearner | Weight 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
?
?
?
總結
以上是生活随笔為你收集整理的Pocketflow 使用的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 怎么去体内的湿热
- 下一篇: 人瘦了体重没减怎么回事