提交 11377e3c 编写于 作者: W wanghaoshuang

Update pages.

上级 95f07a0e
...@@ -128,7 +128,7 @@ SANAS(Simulated Annealing Neural Architecture Search)是基于模拟退火 ...@@ -128,7 +128,7 @@ SANAS(Simulated Annealing Neural Architecture Search)是基于模拟退火
- **tokens(list):** - 一组tokens。tokens的长度和范围取决于搜索空间。 - **tokens(list):** - 一组tokens。tokens的长度和范围取决于搜索空间。
**返回:** **返回:**
根据传入的token得到一个模型结构实例。 根据传入的token得到一个模型结构实例列表
**示例代码:** **示例代码:**
...@@ -153,8 +153,10 @@ SANAS(Simulated Annealing Neural Architecture Search)是基于模拟退火 ...@@ -153,8 +153,10 @@ SANAS(Simulated Annealing Neural Architecture Search)是基于模拟退火
**示例代码:** **示例代码:**
.. code-block:: python .. code-block:: python
import paddle.fluid as fluid import paddle.fluid as fluid
from paddleslim.nas import SANAS from paddleslim.nas import SANAS
config = [('MobileNetV2Space')] config = [('MobileNetV2Space')]
sanas = SANAS(configs=config) sanas = SANAS(configs=config)
print(sanas.current_info()) print(sanas.current_info())
# 多进程蒸馏 # 大规模可扩展知识蒸馏框架 Pantheon
## Teacher ## Teacher
...@@ -100,7 +100,8 @@ pantheon.Teacher.start\_knowledge\_service(feed\_list, schema, program, reader\_ ...@@ -100,7 +100,8 @@ pantheon.Teacher.start\_knowledge\_service(feed\_list, schema, program, reader\_
- **times (int):** The maximum repeated serving times, default 1. Whenever - **times (int):** The maximum repeated serving times, default 1. Whenever
the public method **get\_knowledge\_generator()** in **Student** the public method **get\_knowledge\_generator()** in **Student**
object called once, the serving times will be added one, object called once, the serving times will be added one,
until reaching the maximum and ending the service. until reaching the maximum and ending the service. Only
valid in online mode, and will be ignored in offline mode.
**Return:** None **Return:** None
......
...@@ -378,7 +378,7 @@ load_sensitivities ...@@ -378,7 +378,7 @@ load_sensitivities
} }
} }
sensitivities_file = "sensitive_api_demo.data" sensitivities_file = "sensitive_api_demo.data"
with open(sensitivities_file, 'w') as f: with open(sensitivities_file, 'wb') as f:
pickle.dump(sen, f) pickle.dump(sen, f)
sensitivities = load_sensitivities(sensitivities_file) sensitivities = load_sensitivities(sensitivities_file)
print(sensitivities) print(sensitivities)
......
...@@ -17,3 +17,4 @@ API Documents ...@@ -17,3 +17,4 @@ API Documents
paddleslim.nas.one_shot.rst paddleslim.nas.one_shot.rst
paddleslim.pantheon.rst paddleslim.pantheon.rst
search_space_en.rst search_space_en.rst
table_latency_en.md
# Table about hardware lantency
The table about hardware latency is used to evaluate the inference time in special environment and inference engine. The following text used to introduce the format that PaddleSlim support.
## Introduce
The table about hardware latency saved all possible operations, one operation in the table including type and parameters, such as: type can be `conv2d`, and corresponding parameters can be the size of feature map, number of kernel, and the size of kernel.
The latency of every operation depends on hardware and inference engine.
## Overview format
The table about hardware latency saved in the way of file or multi-line string.
The first line of the table about hardware latency saved the information about version, every line in the following represents a operation and its latency.
## Version
The information about version split by comma in the english format, and the detail is hardware, inference engine and timestamp.
- ** hardware: ** Used to mark the environment of hardware, including type of architecture, version and so on.
- ** inference engine: ** Used to mark inference engine, including the name of inference engine, version, optimize options and so on.
- ** timestamp: ** Used to mark the time of this table created.
## Operation
The information about operation split by comma in the english format, the information about operation and latency split by tabs.
### conv2d
**format**
```text
op_type,flag_bias,flag_relu,n_in,c_in,h_in,w_in,c_out,groups,kernel,padding,stride,dilation\tlatency
```
**introduce**
- **op_type(str)** - The type of this op.
- **flag_bias (int)** - Whether has bias or not(0: donot has bias, 1: has bias).
- **flag_relu (int)** - Whether has relu or not(0: donot has relu, 1: has relu).
- **n_in (int)** - The batch size of input.
- **c_in (int)** - The number of channel about input.
- **h_in (int)** - The height of input feature map.
- **w_in (int)** - The width of input feature map.
- **c_out (int)** - The number of channel about output.
- **groups (int)** - The group of conv2d.
- **kernel (int)** - The size of kernel.
- **padding (int)** - The size of padding.
- **stride (int)** - The size of stride.
- **dilation (int)** - The size of dilation.
- **latency (float)** - The latency of this op.
### activaiton
**format**
```text
op_type,n_in,c_in,h_in,w_in\tlatency
```
**introduce**
- **op_type(str)** - The type of this op.
- **n_in (int)** - The batch size of input.
- **c_in (int)** - The number of channel about input.
- **h_in (int)** - The height of input feature map.
- **w_in (int)** - The width of input feature map.
- **latency (float)** - The latency of this op.
### batch_norm
**format**
```text
op_type,active_type,n_in,c_in,h_in,w_in\tlatency
```
**introduce**
- **op_type(str)** - The type of this op.
- **active_type (string|None)** - The type of activation function, including relu, prelu, sigmoid, relu6, tanh.
- **n_in (int)** - The batch size of input.
- **c_in (int)** - The number of channel about input.
- **h_in (int)** - The height of input feature map.
- **w_in (int)** - The width of input feature map.
- **latency (float)** - The latency of this op.
### eltwise
**format**
```text
op_type,n_in,c_in,h_in,w_in\tlatency
```
**introduce**
- **op_type(str)** - The type of this op.
- **n_in (int)** - The batch size of input.
- **c_in (int)** - The number of channel about input.
- **h_in (int)** - The height of input feature map.
- **w_in (int)** - The width of input feature map.
- **latency (float)** - The latency of this op.
### pooling
**format**
```text
op_type,flag_global_pooling,n_in,c_in,h_in,w_in,kernel,padding,stride,ceil_mode,pool_type\tlatency
```
**introduce**
- **op_type(str)** - The type of this op.
- **flag_global_pooling (int)** - Whether is global pooling or not(0: is not global, 1: is global pooling).
- **n_in (int)** - The batch size of input.
- **c_in (int)** - The number of channel about input.
- **h_in (int)** - The height of input feature map.
- **w_in (int)** - The width of input feature map.
- **kernel (int)** - The size of kernel.
- **padding (int)** - The size of padding.
- **stride (int)** - The size of stride.
- **ceil_mode (int)** - Whether to compute height and width by using ceil function(0: use floor function, 1: use ceil function).
- **pool_type (int)** - The type of pooling(1: max pooling 2: average pooling including padding 3: average pooling excluding padding).
- **latency (float)** - The latency of this op.
### softmax
**format**
```text
op_type,axis,n_in,c_in,h_in,w_in\tlatency
```
**introduce**
- **op_type(str)** - The type of this op.
- **axis (int)** - The index to compute softmax, index in the range of [-1, rank-1], `rank` is the rank of input.
- **n_in (int)** - The batch size of input.
- **c_in (int)** - The number of channel about input.
- **h_in (int)** - The height of input feature map.
- **w_in (int)** - The width of input feature map.
- **latency (float)** - The latency of this op.
...@@ -3,8 +3,8 @@ ...@@ -3,8 +3,8 @@
You can adapt this file completely to your liking, but it should at least You can adapt this file completely to your liking, but it should at least
contain the root `toctree` directive. contain the root `toctree` directive.
Welcome to use PaddleSlim. Index
======== ==============
.. toctree:: .. toctree::
:maxdepth: 1 :maxdepth: 1
...@@ -16,3 +16,5 @@ Welcome to use PaddleSlim. ...@@ -16,3 +16,5 @@ Welcome to use PaddleSlim.
tutorials/index_en tutorials/index_en
api_en/index_en api_en/index_en
model_zoo_en.md model_zoo_en.md
.. mdinclude:: intro_en.md
# Install # Install
安装PaddleSlim前,请确认已正确安装Paddle1.6版本或更新版本。Paddle安装请参考:[Paddle安装教程](https://www.paddlepaddle.org.cn/install/quick)。 Please ensure you have installed PaddlePaddle1.7+. [How to install PaddlePaddle](https://www.paddlepaddle.org.cn/install/quick)。
- 安装develop版本 - Install by pip
```bash ```bash
git clone https://github.com/PaddlePaddle/PaddleSlim.git pip install paddleslim -i https://pypi.org/simple
cd PaddleSlim
python setup.py install
``` ```
- 安装官方发布的最新版本 - Install from source
```bash ```bash
pip install paddleslim -i https://pypi.org/simple git clone https://github.com/PaddlePaddle/PaddleSlim.git
cd PaddleSlim
python setup.py install
``` ```
- 安装历史版本 - History packages
请点击[pypi.org](https://pypi.org/project/paddleslim/#history)查看可安装历史版本。 History packages is available in [pypi.org](https://pypi.org/project/paddleslim/#history).
# 介绍
PaddleSlim是一个模型压缩工具库,包含模型剪裁、定点量化、知识蒸馏、超参搜索和模型结构搜索等一系列模型压缩策略。
# PaddleSlim简介 对于业务用户,PaddleSlim提供完整的模型压缩解决方案,可用于图像分类、检测、分割等各种类型的视觉场景。
同时也在持续探索NLP领域模型的压缩方案。另外,PaddleSlim提供且在不断完善各种压缩策略在经典开源任务的benchmark,
以便业务用户参考。
对于模型压缩算法研究者或开发者,PaddleSlim提供各种压缩策略的底层辅助接口,方便用户复现、调研和使用最新论文方法。
PaddleSlim会从底层能力、技术咨询合作和业务场景等角度支持开发者进行模型压缩策略相关的创新工作。
PaddleSlim是PaddlePaddle框架的一个子模块,主要用于压缩图像领域模型。在PaddleSlim中,不仅实现了目前主流的网络剪枝、量化、蒸馏三种压缩策略,还实现了超参数搜索和小模型网络结构搜索功能。在后续版本中,会添加更多的压缩策略,以及完善对NLP领域模型的支持。
## 功能 ## 功能
- 模型剪裁 - 模型剪裁
- 支持通道均匀模型剪裁(uniform pruning) - 卷积通道均匀剪裁
- 基于敏感度的模型剪裁 - 基于敏感度的卷积通道剪裁
- 基于进化算法的自动模型剪裁三种方式 - 基于进化算法的自动剪裁
- 量化训练 - 定点量化
- 在线量化训练(training aware) - 在线量化训练(training aware)
- 离线量化(post training) - 离线量化(post training)
- 支持对权重全局量化和Channel-Wise量化
- 知识蒸馏 - 知识蒸馏
- 支持单进程知识蒸馏 - 支持单进程知识蒸馏
- 支持多进程分布式知识蒸馏 - 支持多进程分布式知识蒸馏
- 神经网络结构自动搜索(NAS) - 神经网络结构自动搜索(NAS)
- 支持One-Shot网络结构自动搜索(Ont-Shot-NAS) - 支持基于进化算法的轻量神经网络结构自动搜索
- 支持基于进化算法的轻量神经网络结构自动搜索(Light-NAS) - 支持One-Shot网络结构自动搜索
- 支持 FLOPS / 硬件延时约束 - 支持 FLOPS / 硬件延时约束
- 支持多平台模型延时评估 - 支持多平台模型延时评估
- 支持用户自定义搜索算法和搜索空间
## 部分压缩策略效果
### 分类模型
数据: ImageNet2012; 模型: MobileNetV1;
|压缩策略 |精度收益(baseline: 70.91%) |模型大小(baseline: 17.0M)|
|:---:|:---:|:---:|
| 知识蒸馏(ResNet50)| **+1.06%** | |
| 知识蒸馏(ResNet50) + int8量化训练 |**+1.10%**| **-71.76%**|
| 剪裁(FLOPs-50%) + int8量化训练|**-1.71%**|**-86.47%**|
### 图像检测模型
#### 数据:Pascal VOC;模型:MobileNet-V1-YOLOv3
| 压缩方法 | mAP(baseline: 76.2%) | 模型大小(baseline: 94MB) |
| :---------------------: | :------------: | :------------:|
| 知识蒸馏(ResNet34-YOLOv3) | **+2.8%** | |
| 剪裁 FLOPs -52.88% | **+1.4%** | **-67.76%** |
|知识蒸馏(ResNet34-YOLOv3)+剪裁(FLOPs-69.57%)| **+2.6%**|**-67.00%**|
#### 数据:COCO;模型:MobileNet-V1-YOLOv3
| 压缩方法 | mAP(baseline: 29.3%) | 模型大小|
| :---------------------: | :------------: | :------:|
| 知识蒸馏(ResNet34-YOLOv3) | **+2.1%** | |
| 知识蒸馏(ResNet34-YOLOv3)+剪裁(FLOPs-67.56%) | **-0.3%** | **-66.90%**|
### 搜索
数据:ImageNet2012; 模型:MobileNetV2
|硬件环境 | 推理耗时 | Top1准确率(baseline:71.90%) |
|:---------------:|:---------:|:--------------------:|
| RK3288 | **-23%** | +0.07% |
| Android cellphone | **-20%** | +0.16% |
| iPhone 6s | **-17%** | +0.32% |
# Introduction
PaddleSlim is a toolkit for model compression. It contains a collection of compression strategies, such as pruning, fixed point quantization, knowledge distillation, hyperparameter searching and neural architecture search.
# Introduction PaddleSlim provides solutions of compression on computer vision models, such as image classification, object detection and semantic segmentation. Meanwhile, PaddleSlim Keeps exploring advanced compression strategies for language model. Furthermore, benckmark of compression strategies on some open tasks is available for your reference.
PaddleSlim also provides auxiliary and primitive API for developer and researcher to survey, implement and apply the method in latest papers. PaddleSlim will support developer in ability of framework and technology consulting.
## Features
### Pruning
- Uniform pruning of convolution
- Sensitivity-based prunning
- Automated pruning based evolution search strategy
- Support pruning of various deep architectures such as VGG, ResNet, and MobileNet.
- Support self-defined range of pruning, i.e., layers to be pruned.
### Fixed Point Quantization
- **Training aware**
- Dynamic strategy: During inference, we quantize models with hyperparameters dynamically estimated from small batches of samples.
- Static strategy: During inference, we quantize models with the same hyperparameters estimated from training data.
- Support layer-wise and channel-wise quantization.
- **Post training**
### Knowledge Distillation
- **Naive knowledge distillation:** transfers dark knowledge by merging the teacher and student model into the same Program
- **Paddle large-scale scalable knowledge distillation framework Pantheon:** a universal solution for knowledge distillation, more flexible than the naive knowledge distillation, and easier to scale to the large-scale applications.
- Decouple the teacher and student models --- they run in different processes in the same or different nodes, and transfer knowledge via TCP/IP ports or local files;
- Friendly to assemble multiple teacher models and each of them can work in either online or offline mode independently;
- Merge knowledge from different teachers and make batch data for the student model automatically;
- Support the large-scale knowledge prediction of teacher models on multiple devices.
### Neural Architecture Search
- Neural architecture search based on evolution strategy.
- Support distributed search.
- One-Shot neural architecture search.
- Support FLOPs and latency constrained search.
- Support the latency estimation on different hardware and platforms.
## Performance
### Image Classification
Dataset: ImageNet2012; Model: MobileNetV1;
|Method |Accuracy(baseline: 70.91%) |Model Size(baseline: 17.0M)|
|:---:|:---:|:---:|
| Knowledge Distillation(ResNet50)| **+1.06%** | |
| Knowledge Distillation(ResNet50) + int8 quantization |**+1.10%**| **-71.76%**|
| Pruning(FLOPs-50%) + int8 quantization|**-1.71%**|**-86.47%**|
### Object Detection
#### Dataset: Pascal VOC; Model: MobileNet-V1-YOLOv3
As a submodule of PaddlePaddle framework, PaddleSlim is an open-source library for deep model compression and architecture search. PaddleSlim supports current popular deep compression techniques such as pruning, quantization, and knowledge distillation. Further, it also automates the search of hyperparameters and the design of lightweight deep architectures. In the future, we will develop more practically useful compression techniques for industrial-level applications and transfer these techniques to models in NLP. | Method | mAP(baseline: 76.2%) | Model Size(baseline: 94MB) |
| :---------------------: | :------------: | :------------:|
| Knowledge Distillation(ResNet34-YOLOv3) | **+2.8%** | |
| Pruning(FLOPs -52.88%) | **+1.4%** | **-67.76%** |
|Knowledge DistillationResNet34-YOLOv3)+Pruning(FLOPs-69.57%)| **+2.6%**|**-67.00%**|
## Methods #### Dataset: COCO; Model: MobileNet-V1-YOLOv3
- Pruning | Method | mAP(baseline: 29.3%) | Model Size|
- Uniform pruning | :---------------------: | :------------: | :------:|
- Sensitivity-based pruning | Knowledge Distillation(ResNet34-YOLOv3) | **+2.1%** |-|
- Automated model pruning | Knowledge Distillation(ResNet34-YOLOv3)+Pruning(FLOPs-67.56%) | **-0.3%** | **-66.90%**|
- Quantization ### NAS
- Training-aware quantization: Quantize models with hyperparameters dynamically estimated from small batches of samples.
- Training-aware quantization: Quantize models with the same hyperparameters estimated from training data.
- Support global quantization of weights and Channel-Wise quantization
- Knowledge Distillation Dataset: ImageNet2012; Model: MobileNetV2
- Single-process knowledge distillation
- Multi-process distributed knowledge distillation
- Network Architecture Search(NAS) |Device | Infer time cost | Top1 accuracy(baseline:71.90%) |
- Simulated Annealing (SA)-based lightweight network architecture search method.(Light-NAS) |:---------------:|:---------:|:--------------------:|
- One-Shot network structure automatic search. (One-Shot-NAS) | RK3288 | **-23%** | +0.07% |
- PaddleSlim supports FLOPs and latency constrained search. | Android cellphone | **-20%** | +0.16% |
- PaddleSlim supports the latency estimation on different hardware and platforms. | iPhone 6s | **-17%** | +0.32% |
# 模型库 # 模型库
## 1. 图分类 ## 1. 图分类
数据集:ImageNet1000类 数据集:ImageNet1000类
...@@ -57,19 +57,26 @@ ...@@ -57,19 +57,26 @@
### 1.2 剪裁 ### 1.2 剪裁
| 模型 | 压缩方法 | Top-1/Top-5 Acc | 模型体积(MB) | GFLOPs | 下载 | PaddleLite推理耗时说明:
|:--:|:---:|:--:|:--:|:--:|:--:|
| MobileNetV1 | Baseline | 70.99%/89.68% | 17 | 1.11 | [下载链接](http://paddle-imagenet-models-name.bj.bcebos.com/MobileNetV1_pretrained.tar) | 环境:Qualcomm SnapDragon 845 + armv8
| MobileNetV1 | uniform -50% | 69.4%/88.66% (-1.59%/-1.02%) | 9 | 0.56 | [下载链接](https://paddlemodels.bj.bcebos.com/PaddleSlim/MobileNetV1_uniform-50.tar) |
| MobileNetV1 | sensitive -30% | 70.4%/89.3% (-0.59%/-0.38%) | 12 | 0.74 | [下载链接](https://paddlemodels.bj.bcebos.com/PaddleSlim/MobileNetV1_sensitive-30.tar) |
| MobileNetV1 | sensitive -50% | 69.8% / 88.9% (-1.19%/-0.78%) | 9 | 0.56 | [下载链接](https://paddlemodels.bj.bcebos.com/PaddleSlim/MobileNetV1_sensitive-50.tar) |
| MobileNetV2 | - | 72.15%/90.65% | 15 | 0.59 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/MobileNetV2_pretrained.tar) |
| MobileNetV2 | uniform -50% | 65.79%/86.11% (-6.35%/-4.47%) | 11 | 0.296 | [下载链接](https://paddlemodels.bj.bcebos.com/PaddleSlim/MobileNetV2_uniform-50.tar) |
| ResNet34 | - | 72.15%/90.65% | 84 | 7.36 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/ResNet34_pretrained.tar) |
| ResNet34 | uniform -50% | 70.99%/89.95% (-1.36%/-0.87%) | 41 | 3.67 | [下载链接](https://paddlemodels.bj.bcebos.com/PaddleSlim/ResNet34_uniform-50.tar) |
| ResNet34 | auto -55.05% | 70.24%/89.63% (-2.04%/-1.06%) | 33 | 3.31 | [下载链接](https://paddlemodels.bj.bcebos.com/PaddleSlim/ResNet34_auto-55.tar) |
速度指标:Thread1/Thread2/Thread4耗时
PaddleLite版本: v2.3
| 模型 | 压缩方法 | Top-1/Top-5 Acc | 模型体积(MB) | GFLOPs |PaddleLite推理耗时|TensorRT推理速度(FPS)| 下载 |
|:--:|:---:|:--:|:--:|:--:|:--:|:--:|:--:|
| MobileNetV1 | Baseline | 70.99%/89.68% | 17 | 1.11 |66.052\35.8014\19.5762|-| [下载链接](http://paddle-imagenet-models-name.bj.bcebos.com/MobileNetV1_pretrained.tar) |
| MobileNetV1 | uniform -50% | 69.4%/88.66% (-1.59%/-1.02%) | 9 | 0.56 | 33.5636\18.6834\10.5076|-|[下载链接](https://paddlemodels.bj.bcebos.com/PaddleSlim/MobileNetV1_uniform-50.tar) |
| MobileNetV1 | sensitive -30% | 70.4%/89.3% (-0.59%/-0.38%) | 12 | 0.74 | 46.5958\25.3098\13.6982|-|[下载链接](https://paddlemodels.bj.bcebos.com/PaddleSlim/MobileNetV1_sensitive-30.tar) |
| MobileNetV1 | sensitive -50% | 69.8% / 88.9% (-1.19%/-0.78%) | 9 | 0.56 |37.9892\20.7882\11.3144|-| [下载链接](https://paddlemodels.bj.bcebos.com/PaddleSlim/MobileNetV1_sensitive-50.tar) |
| MobileNetV2 | - | 72.15%/90.65% | 15 | 0.59 |41.7874\23.375\13.3998|-| [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/MobileNetV2_pretrained.tar) |
| MobileNetV2 | uniform -50% | 65.79%/86.11% (-6.35%/-4.47%) | 11 | 0.296 |23.8842\13.8698\8.5572|-| [下载链接](https://paddlemodels.bj.bcebos.com/PaddleSlim/MobileNetV2_uniform-50.tar) |
| ResNet34 | - | 72.15%/90.65% | 84 | 7.36 |217.808\139.943\96.7504|342.32| [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/ResNet34_pretrained.tar) |
| ResNet34 | uniform -50% | 70.99%/89.95% (-1.36%/-0.87%) | 41 | 3.67 |114.787\75.0332\51.8438|452.41| [下载链接](https://paddlemodels.bj.bcebos.com/PaddleSlim/ResNet34_uniform-50.tar) |
| ResNet34 | auto -55.05% | 70.24%/89.63% (-2.04%/-1.06%) | 33 | 3.31 |105.924\69.3222\48.0246|457.25| [下载链接](https://paddlemodels.bj.bcebos.com/PaddleSlim/ResNet34_auto-55.tar) |
### 1.3 蒸馏 ### 1.3 蒸馏
...@@ -85,10 +92,25 @@ ...@@ -85,10 +92,25 @@
|ResNet101|teacher|77.56%/93.64%| 173 | [下载链接](http://paddle-imagenet-models-name.bj.bcebos.com/ResNet101_pretrained.tar) | |ResNet101|teacher|77.56%/93.64%| 173 | [下载链接](http://paddle-imagenet-models-name.bj.bcebos.com/ResNet101_pretrained.tar) |
| ResNet50 | ResNet101 distill | 77.29%/93.65% (+0.79%/+0.65%) | 99 | [下载链接](https://paddlemodels.bj.bcebos.com/PaddleSlim/ResNet50_distilled.tar) | | ResNet50 | ResNet101 distill | 77.29%/93.65% (+0.79%/+0.65%) | 99 | [下载链接](https://paddlemodels.bj.bcebos.com/PaddleSlim/ResNet50_distilled.tar) |
!!! note "Note" 注意:带"_vd"后缀代表该预训练模型使用了Mixup,Mixup相关介绍参考[mixup: Beyond Empirical Risk Minimization](https://arxiv.org/abs/1710.09412)
### 1.4 搜索
<a name="trans1">[1]</a>:带_vd后缀代表该预训练模型使用了Mixup,Mixup相关介绍参考[mixup: Beyond Empirical Risk Minimization](https://arxiv.org/abs/1710.09412) 数据集: ImageNet1000
| 模型 | 压缩方法 | Top-1/Top-5 Acc | 模型体积(MB) | GFLOPs | 下载 |
|:--:|:---:|:--:|:--:|:--:|:--:|
| MobileNetV2 | - | 72.15%/90.65% | 15 | 0.59 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/MobileNetV2_pretrained.tar) |
| MobileNetV2 | SANAS | 71.518%/90.208% (-0.632%/-0.442%) | 14 | 0.295 | [下载链接](https://paddlemodels.cdn.bcebos.com/PaddleSlim/MobileNetV2_sanas.tar) |
数据集: Cifar10
| 模型 |压缩方法 | Acc | 模型参数(MB) | 下载 |
|:---:|:--:|:--:|:--:|:--:|
| Darts | - | 97.135% | 3.767 | - |
| Darts_SA(基于Darts搜索空间) | SANAS | 97.276%(+0.141%) | 3.344(-11.2%) | - |
Note: MobileNetV2_NAS 的token是:[4, 4, 5, 1, 1, 2, 1, 1, 0, 2, 6, 2, 0, 3, 4, 5, 0, 4, 5, 5, 1, 4, 8, 0, 0]. Darts_SA的token是:[5, 5, 0, 5, 5, 10, 7, 7, 5, 7, 7, 11, 10, 12, 10, 0, 5, 3, 10, 8].
## 2. 目标检测 ## 2. 目标检测
...@@ -127,20 +149,29 @@ ...@@ -127,20 +149,29 @@
### 2.2 剪裁 ### 2.2 剪裁
数据集:Pasacl VOC & COCO 2017 数据集:Pasacl VOC & COCO 2017
| 模型 | 压缩方法 | 数据集 | Image/GPU | 输入608 Box AP | 输入416 Box AP | 输入320 Box AP | 模型体积(MB) | GFLOPs (608*608) | 下载 | PaddleLite推理耗时说明:
| :----------------------------: | :---------------: | :--------: | :-------: | :------------: | :------------: | :------------: | :----------: | :--------------: | :----------------------------------------------------------: |
| MobileNet-V1-YOLOv3 | Baseline | Pascal VOC | 8 | 76.2 | 76.7 | 75.3 | 94 | 40.49 | [下载链接](https://paddlemodels.bj.bcebos.com/object_detection/yolov3_mobilenet_v1_voc.tar) | 环境:Qualcomm SnapDragon 845 + armv8
| MobileNet-V1-YOLOv3 | sensitive -52.88% | Pascal VOC | 8 | 77.6 (+1.4) | 77.7 (1.0) | 75.5 (+0.2) | 31 | 19.08 | [下载链接](https://paddlemodels.bj.bcebos.com/PaddleSlim/yolov3_mobilenet_v1_voc_prune.tar) |
| MobileNet-V1-YOLOv3 | - | COCO | 8 | 29.3 | 29.3 | 27.0 | 95 | 41.35 | [下载链接](https://paddlemodels.bj.bcebos.com/object_detection/yolov3_mobilenet_v1.tar) | 速度指标:Thread1/Thread2/Thread4耗时
| MobileNet-V1-YOLOv3 | sensitive -51.77% | COCO | 8 | 26.0 (-3.3) | 25.1 (-4.2) | 22.6 (-4.4) | 32 | 19.94 | [下载链接](https://paddlemodels.bj.bcebos.com/PaddleSlim/yolov3_mobilenet_v1_prune.tar) |
| R50-dcn-YOLOv3 | - | COCO | 8 | 39.1 | - | - | 177 | 89.60 | [下载链接](https://paddlemodels.bj.bcebos.com/object_detection/yolov3_r50vd_dcn.tar) | PaddleLite版本: v2.3
| R50-dcn-YOLOv3 | sensitive -9.37% | COCO | 8 | 39.3 (+0.2) | - | - | 150 | 81.20 | [下载链接](https://paddlemodels.bj.bcebos.com/PaddleSlim/yolov3_r50vd_dcn_prune.tar) |
| R50-dcn-YOLOv3 | sensitive -24.68% | COCO | 8 | 37.3 (-1.8) | - | - | 113 | 67.48 | [下载链接](https://paddlemodels.bj.bcebos.com/PaddleSlim/yolov3_r50vd_dcn_prune578.tar) | | 模型 | 压缩方法 | 数据集 | Image/GPU | 输入608 Box AP | 输入416 Box AP | 输入320 Box AP | 模型体积(MB) | GFLOPs (608*608) | PaddleLite推理耗时(ms)(608*608) | TensorRT推理速度(FPS)(608*608) | 下载 |
| R50-dcn-YOLOv3 obj365_pretrain | - | COCO | 8 | 41.4 | - | - | 177 | 89.60 | [下载链接](https://paddlemodels.bj.bcebos.com/object_detection/yolov3_r50vd_dcn_obj365_pretrained_coco.tar) | | :----------------------------: | :---------------: | :--------: | :-------: | :------------: | :------------: | :------------: | :----------: | :--------------: | :--------------: | :--------------: | :-----------------------------------: |
| R50-dcn-YOLOv3 obj365_pretrain | sensitive -9.37% | COCO | 8 | 40.5 (-0.9) | - | - | 150 | 81.20 | [下载链接](https://paddlemodels.bj.bcebos.com/PaddleSlim/yolov3_r50vd_dcn_obj365_pretrained_coco_prune.tar) | | MobileNet-V1-YOLOv3 | Baseline | Pascal VOC | 8 | 76.2 | 76.7 | 75.3 | 94 | 40.49 | 1238\796.943\520.101|60.04| [下载链接](https://paddlemodels.bj.bcebos.com/object_detection/yolov3_mobilenet_v1_voc.tar) |
| R50-dcn-YOLOv3 obj365_pretrain | sensitive -24.68% | COCO | 8 | 37.8 (-3.3) | - | - | 113 | 67.48 | [下载链接](https://paddlemodels.bj.bcebos.com/PaddleSlim/yolov3_r50vd_dcn_obj365_pretrained_coco_prune578.tar) | | MobileNet-V1-YOLOv3 | sensitive -52.88% | Pascal VOC | 8 | 77.6 (+1.4) | 77.7 (1.0) | 75.5 (+0.2) | 31 | 19.08 | 602.497\353.759\222.427 |99.36| [下载链接](https://paddlemodels.bj.bcebos.com/PaddleSlim/yolov3_mobilenet_v1_voc_prune.tar) |
| MobileNet-V1-YOLOv3 | - | COCO | 8 | 29.3 | 29.3 | 27.0 | 95 | 41.35 |-|-| [下载链接](https://paddlemodels.bj.bcebos.com/object_detection/yolov3_mobilenet_v1.tar) |
| MobileNet-V1-YOLOv3 | sensitive -51.77% | COCO | 8 | 26.0 (-3.3) | 25.1 (-4.2) | 22.6 (-4.4) | 32 | 19.94 |-|73.93| [下载链接](https://paddlemodels.bj.bcebos.com/PaddleSlim/yolov3_mobilenet_v1_prune.tar) |
| R50-dcn-YOLOv3 | - | COCO | 8 | 39.1 | - | - | 177 | 89.60 |-|27.68| [下载链接](https://paddlemodels.bj.bcebos.com/object_detection/yolov3_r50vd_dcn.tar) |
| R50-dcn-YOLOv3 | sensitive -9.37% | COCO | 8 | 39.3 (+0.2) | - | - | 150 | 81.20 |-|30.08| [下载链接](https://paddlemodels.bj.bcebos.com/PaddleSlim/yolov3_r50vd_dcn_prune.tar) |
| R50-dcn-YOLOv3 | sensitive -24.68% | COCO | 8 | 37.3 (-1.8) | - | - | 113 | 67.48 |-|34.32| [下载链接](https://paddlemodels.bj.bcebos.com/PaddleSlim/yolov3_r50vd_dcn_prune578.tar) |
| R50-dcn-YOLOv3 obj365_pretrain | - | COCO | 8 | 41.4 | - | - | 177 | 89.60 |-|-| [下载链接](https://paddlemodels.bj.bcebos.com/object_detection/yolov3_r50vd_dcn_obj365_pretrained_coco.tar) |
| R50-dcn-YOLOv3 obj365_pretrain | sensitive -9.37% | COCO | 8 | 40.5 (-0.9) | - | - | 150 | 81.20 |-|-| [下载链接](https://paddlemodels.bj.bcebos.com/PaddleSlim/yolov3_r50vd_dcn_obj365_pretrained_coco_prune.tar) |
| R50-dcn-YOLOv3 obj365_pretrain | sensitive -24.68% | COCO | 8 | 37.8 (-3.3) | - | - | 113 | 67.48 |-|-| [下载链接](https://paddlemodels.bj.bcebos.com/PaddleSlim/yolov3_r50vd_dcn_obj365_pretrained_coco_prune578.tar) |
### 2.3 蒸馏 ### 2.3 蒸馏
...@@ -157,6 +188,18 @@ ...@@ -157,6 +188,18 @@
| MobileNet-V1-YOLOv3 | ResNet34-YOLOv3 distill | COCO | 8 | 31.4 (+2.1) | 30.0 (+0.7) | 27.1 (+0.1) | 95 | [下载链接](https://paddlemodels.bj.bcebos.com/PaddleSlim/yolov3_mobilenetv1_coco_distilled.tar) | | MobileNet-V1-YOLOv3 | ResNet34-YOLOv3 distill | COCO | 8 | 31.4 (+2.1) | 30.0 (+0.7) | 27.1 (+0.1) | 95 | [下载链接](https://paddlemodels.bj.bcebos.com/PaddleSlim/yolov3_mobilenetv1_coco_distilled.tar) |
### 2.4 搜索
数据集:WIDER-FACE
| 模型 | 压缩方法 | Image/GPU | 输入尺寸 | Easy/Medium/Hard | 模型体积(KB) | 硬件延时(ms)| 下载 |
| :------------: | :---------: | :-------: | :------: | :-----------------------------: | :------------: | :------------: | :----------------------------------------------------------: |
| BlazeFace | - | 8 | 640 | 91.5/89.2/79.7 | 815 | 71.862 | [下载链接](https://paddlemodels.bj.bcebos.com/object_detection/blazeface_original.tar) |
| BlazeFace-NAS | - | 8 | 640 | 83.7/80.7/65.8 | 244 | 21.117 |[下载链接](https://paddlemodels.bj.bcebos.com/object_detection/blazeface_nas.tar) |
| BlazeFace-NASV2 | SANAS | 8 | 640 | 87.0/83.7/68.5 | 389 | 22.558 | [下载链接](https://paddlemodels.bj.bcebos.com/object_detection/blazeface_nas2.tar) |
Note: 硬件延时时间是利用提供的硬件延时表得到的,硬件延时表是在855芯片上基于PaddleLite测试的结果。BlazeFace-NASV2的详细配置在[这里](https://github.com/PaddlePaddle/PaddleDetection/blob/master/configs/face_detection/blazeface_nas_v2.yml).
## 3. 图像分割 ## 3. 图像分割
数据集:Cityscapes 数据集:Cityscapes
...@@ -201,8 +244,16 @@ ...@@ -201,8 +244,16 @@
### 3.2 剪裁 ### 3.2 剪裁
| 模型 | 压缩方法 | mIoU | 模型体积(MB) | GFLOPs | 下载 | PaddleLite推理耗时说明:
| :-------: | :---------------: | :-----------: | :------------: | :----: | :----------------------------------------------------------: |
| fast-scnn | baseline | 69.64 | 11 | 14.41 | [下载链接](https://paddlemodels.bj.bcebos.com/PaddleSlim/fast_scnn_cityscape.tar) | 环境:Qualcomm SnapDragon 845 + armv8
| fast-scnn | uniform -17.07% | 69.58 (-0.06) | 8.5 | 11.95 | [下载链接](https://paddlemodels.bj.bcebos.com/PaddleSlim/fast_scnn_cityscape_uniform-17.tar) |
| fast-scnn | sensitive -47.60% | 66.68 (-2.96) | 5.7 | 7.55 | [下载链接](https://paddlemodels.bj.bcebos.com/PaddleSlim/fast_scnn_cityscape_sensitive-47.tar) | 速度指标:Thread1/Thread2/Thread4耗时
PaddleLite版本: v2.3
| 模型 | 压缩方法 | mIoU | 模型体积(MB) | GFLOPs | PaddleLite推理耗时 | TensorRT推理速度(FPS) | 下载 |
| :-------: | :---------------: | :-----------: | :------------: | :----: | :------------: | :----: | :--------------------------------------: |
| fast-scnn | baseline | 69.64 | 11 | 14.41 | 1226.36\682.96\415.664 |39.53| [下载链接](https://paddlemodels.bj.bcebos.com/PaddleSlim/fast_scnn_cityscape.tar) |
| fast-scnn | uniform -17.07% | 69.58 (-0.06) | 8.5 | 11.95 | 1140.37\656.612\415.888 |42.01| [下载链接](https://paddlemodels.bj.bcebos.com/PaddleSlim/fast_scnn_cityscape_uniform-17.tar) |
| fast-scnn | sensitive -47.60% | 66.68 (-2.96) | 5.7 | 7.55 | 866.693\494.467\291.748 |51.48| [下载链接](https://paddlemodels.bj.bcebos.com/PaddleSlim/fast_scnn_cityscape_sensitive-47.tar) |
# Model Zoo # Model Zoo
## 1. 图象分类 ## 1. Image Classification
数据集:ImageNet1000类 Dataset:ImageNet1000
### 1.1 量化 ### 1.1 Quantization
| 模型 | 压缩方法 | Top-1/Top-5 Acc | 模型体积(MB) | 下载 | | Model | Method | Top-1/Top-5 Acc | Model Size(MB) | TensorRT latency(V100, ms) | Download |
|:--:|:---:|:--:|:--:|:--:|:--:|
|MobileNetV1|-|70.99%/89.68%| 17 | -| [model](http://paddle-imagenet-models-name.bj.bcebos.com/MobileNetV1_pretrained.tar) |
|MobileNetV1|quant_post|70.18%/89.25% (-0.81%/-0.43%)| 4.4 | - | [model](https://paddlemodels.bj.bcebos.com/PaddleSlim/MobileNetV1_quant_post.tar) |
|MobileNetV1|quant_aware|70.60%/89.57% (-0.39%/-0.11%)| 4.4 | -| [model](https://paddlemodels.bj.bcebos.com/PaddleSlim/MobileNetV1_quant_aware.tar) |
| MobileNetV2 | - |72.15%/90.65%| 15 | - | [model](https://paddle-imagenet-models-name.bj.bcebos.com/MobileNetV2_pretrained.tar) |
| MobileNetV2 | quant_post | 71.15%/90.11% (-1%/-0.54%)| 4.0 | - | [model](https://paddlemodels.bj.bcebos.com/PaddleSlim/MobileNetV2_quant_post.tar) |
| MobileNetV2 | quant_aware |72.05%/90.63% (-0.1%/-0.02%)| 4.0 | - | [model](https://paddlemodels.bj.bcebos.com/PaddleSlim/MobileNetV2_quant_aware.tar) |
|ResNet50|-|76.50%/93.00%| 99 | 2.71 | [model](http://paddle-imagenet-models-name.bj.bcebos.com/ResNet50_pretrained.tar) |
|ResNet50|quant_post|76.33%/93.02% (-0.17%/+0.02%)| 25.1| 1.19 | [model](https://paddlemodels.bj.bcebos.com/PaddleSlim/ResNet50_quant_post.tar) |
|ResNet50|quant_aware| 76.48%/93.11% (-0.02%/+0.11%)| 25.1 | 1.17 | [model](https://paddlemodels.bj.bcebos.com/PaddleSlim/ResNet50_quant_awre.tar) |
PaddleLite latency(ms)
| Device | Model | Method | armv7 Thread 1 | armv7 Thread 2 | armv7 Thread 4 | armv8 Thread 1 | armv8 Thread 2 | armv8 Thread 4 |
| ------- | ----------- | ------------- | -------------- | -------------- | -------------- | -------------- | -------------- | -------------- |
| Qualcomm 835 | MobileNetV1 | FP32 baseline | 96.1942 | 53.2058 | 32.4468 | 88.4955 | 47.95 | 27.5189 |
| Qualcomm 835 | MobileNetV1 | quant_aware | 60.8186 | 32.1931 | 16.4275 | 56.4311 | 29.5446 | 15.1053 |
| Qualcomm 835 | MobileNetV1 | quant_post | 60.5615 | 32.4016 | 16.6596 | 56.5266 | 29.7178 | 15.1459 |
| Qualcomm 835 | MobileNetV2 | FP32 baseline | 65.715 | 38.1346 | 25.155 | 61.3593 | 36.2038 | 22.849 |
| Qualcomm 835 | MobileNetV2 | quant_aware | 48.3655 | 30.2021 | 21.9303 | 46.1487 | 27.3146 | 18.3053 |
| Qualcomm 835 | MobileNetV2 | quant_post | 48.3495 | 30.3069 | 22.1506 | 45.8715 | 27.4105 | 18.2223 |
| Qualcomm 835 | ResNet50 | FP32 baseline | 526.811 | 319.6486 | 205.8345 | 506.1138 | 335.1584 | 214.8936 |
| Qualcomm 835 | ResNet50 | quant_aware | 475.4538 | 256.8672 | 139.699 | 461.7344 | 247.9506 | 145.9847 |
| Qualcomm 835 | ResNet50 | quant_post | 476.0507 | 256.5963 | 139.7266 | 461.9176 | 248.3795 | 149.353 |
| Qualcomm 855 | MobileNetV1 | FP32 baseline | 33.5086 | 19.5773 | 11.7534 | 31.3474 | 18.5382 | 10.0811 |
| Qualcomm 855 | MobileNetV1 | quant_aware | 36.7067 | 21.628 | 11.0372 | 14.0238 | 8.199 | 4.2588 |
| Qualcomm 855 | MobileNetV1 | quant_post | 37.0498 | 21.7081 | 11.0779 | 14.0947 | 8.1926 | 4.2934 |
| Qualcomm 855 | MobileNetV2 | FP32 baseline | 25.0396 | 15.2862 | 9.6609 | 22.909 | 14.1797 | 8.8325 |
| Qualcomm 855 | MobileNetV2 | quant_aware | 28.1583 | 18.3317 | 11.8103 | 16.9158 | 11.1606 | 7.4148 |
| Qualcomm 855 | MobileNetV2 | quant_post | 28.1631 | 18.3917 | 11.8333 | 16.9399 | 11.1772 | 7.4176 |
| Qualcomm 855 | ResNet50 | FP32 baseline | 185.3705 | 113.0825 | 87.0741 | 177.7367 | 110.0433 | 74.4114 |
| Qualcomm 855 | ResNet50 | quant_aware | 327.6883 | 202.4536 | 106.243 | 243.5621 | 150.0542 | 78.4205 |
| Qualcomm 855 | ResNet50 | quant_post | 328.2683 | 201.9937 | 106.744 | 242.6397 | 150.0338 | 79.8659 |
| Kirin 970 | MobileNetV1 | FP32 baseline | 101.2455 | 56.4053 | 35.6484 | 94.8985 | 51.7251 | 31.9511 |
| Kirin 970 | MobileNetV1 | quant_aware | 62.5012 | 32.1863 | 16.6018 | 57.7477 | 29.2116 | 15.0703 |
| Kirin 970 | MobileNetV1 | quant_post | 62.4412 | 32.2585 | 16.6215 | 57.825 | 29.2573 | 15.1206 |
| Kirin 970 | MobileNetV2 | FP32 baseline | 70.4176 | 42.0795 | 25.1939 | 68.9597 | 39.2145 | 22.6617 |
| Kirin 970 | MobileNetV2 | quant_aware | 52.9961 | 31.5323 | 22.1447 | 49.4858 | 28.0856 | 18.7287 |
| Kirin 970 | MobileNetV2 | quant_post | 53.0961 | 31.7987 | 21.8334 | 49.383 | 28.2358 | 18.3642 |
| Kirin 970 | ResNet50 | FP32 baseline | 586.8943 | 344.0858 | 228.2293 | 573.3344 | 351.4332 | 225.8006 |
| Kirin 970 | ResNet50 | quant_aware | 488.361 | 260.1697 | 142.416 | 479.5668 | 249.8485 | 138.1742 |
| Kirin 970 | ResNet50 | quant_post | 489.6188 | 258.3279 | 142.6063 | 480.0064 | 249.5339 | 138.5284 |
### 1.2 Pruning
PaddleLite:
env: Qualcomm SnapDragon 845 + armv8
criterion: time cost in Thread1/Thread2/Thread4
PaddleLite version: v2.3
|Model | Method | Top-1/Top-5 Acc | ModelSize(MB) | GFLOPs |PaddleLite cost(ms)|TensorRT speed(FPS)| download |
|:--:|:---:|:--:|:--:|:--:|:--:|:--:|:--:|
| MobileNetV1 | Baseline | 70.99%/89.68% | 17 | 1.11 |66.052\35.8014\19.5762|-| [download](http://paddle-imagenet-models-name.bj.bcebos.com/MobileNetV1_pretrained.tar) |
| MobileNetV1 | uniform -50% | 69.4%/88.66% (-1.59%/-1.02%) | 9 | 0.56 | 33.5636\18.6834\10.5076|-|[download](https://paddlemodels.bj.bcebos.com/PaddleSlim/MobileNetV1_uniform-50.tar) |
| MobileNetV1 | sensitive -30% | 70.4%/89.3% (-0.59%/-0.38%) | 12 | 0.74 | 46.5958\25.3098\13.6982|-|[download](https://paddlemodels.bj.bcebos.com/PaddleSlim/MobileNetV1_sensitive-30.tar) |
| MobileNetV1 | sensitive -50% | 69.8% / 88.9% (-1.19%/-0.78%) | 9 | 0.56 |37.9892\20.7882\11.3144|-| [download](https://paddlemodels.bj.bcebos.com/PaddleSlim/MobileNetV1_sensitive-50.tar) |
| MobileNetV2 | - | 72.15%/90.65% | 15 | 0.59 |41.7874\23.375\13.3998|-| [download](https://paddle-imagenet-models-name.bj.bcebos.com/MobileNetV2_pretrained.tar) |
| MobileNetV2 | uniform -50% | 65.79%/86.11% (-6.35%/-4.47%) | 11 | 0.296 |23.8842\13.8698\8.5572|-| [download](https://paddlemodels.bj.bcebos.com/PaddleSlim/MobileNetV2_uniform-50.tar) |
| ResNet34 | - | 72.15%/90.65% | 84 | 7.36 |217.808\139.943\96.7504|342.32| [download](https://paddle-imagenet-models-name.bj.bcebos.com/ResNet34_pretrained.tar) |
| ResNet34 | uniform -50% | 70.99%/89.95% (-1.36%/-0.87%) | 41 | 3.67 |114.787\75.0332\51.8438|452.41| [download](https://paddlemodels.bj.bcebos.com/PaddleSlim/ResNet34_uniform-50.tar) |
| ResNet34 | auto -55.05% | 70.24%/89.63% (-2.04%/-1.06%) | 33 | 3.31 |105.924\69.3222\48.0246|457.25| [download](https://paddlemodels.bj.bcebos.com/PaddleSlim/ResNet34_auto-55.tar) |
### 1.3 Distillation
| Model | Method | Top-1/Top-5 Acc | Model Size(MB) | Download |
|:--:|:---:|:--:|:--:|:--:| |:--:|:---:|:--:|:--:|:--:|
|MobileNetV1|-|70.99%/89.68%| xx | [下载链接]() | | MobileNetV1 | student | 70.99%/89.68% | 17 | [model](http://paddle-imagenet-models-name.bj.bcebos.com/MobileNetV1_pretrained.tar) |
|MobileNetV1|quant_post|xx%/xx%| xx | [下载链接]() | |ResNet50_vd|teacher|79.12%/94.44%| 99 | [model](https://paddle-imagenet-models-name.bj.bcebos.com/ResNet50_vd_pretrained.tar) |
|MobileNetV1|quant_aware|xx%/xx%| xx | [下载链接]() | |MobileNetV1|ResNet50_vd<sup>[1](#trans1)</sup> distill|72.77%/90.68% (+1.78%/+1.00%)| 17 | [model](https://paddlemodels.bj.bcebos.com/PaddleSlim/MobileNetV1_distilled.tar) |
| MobileNetV2 | - |72.15%/90.65%| xx | [下载链接]() | | MobileNetV2 | student | 72.15%/90.65% | 15 | [model](https://paddle-imagenet-models-name.bj.bcebos.com/MobileNetV2_pretrained.tar) |
| MobileNetV2 | quant_post |xx%/xx%| xx | [下载链接]() | | MobileNetV2 | ResNet50_vd distill | 74.28%/91.53% (+2.13%/+0.88%) | 15 | [model](https://paddlemodels.bj.bcebos.com/PaddleSlim/MobileNetV2_distilled.tar) |
| MobileNetV2 | quant_aware |xx%/xx%| xx | [下载链接]() | | ResNet50 | student | 76.50%/93.00% | 99 | [model](http://paddle-imagenet-models-name.bj.bcebos.com/ResNet50_pretrained.tar) |
|ResNet50|-|76.50%/93.00%| xx | [下载链接]() | |ResNet101|teacher|77.56%/93.64%| 173 | [model](http://paddle-imagenet-models-name.bj.bcebos.com/ResNet101_pretrained.tar) |
|ResNet50|quant_post|xx%/xx%| xx | [下载链接]() | | ResNet50 | ResNet101 distill | 77.29%/93.65% (+0.79%/+0.65%) | 99 | [model](https://paddlemodels.bj.bcebos.com/PaddleSlim/ResNet50_distilled.tar) |
|ResNet50|quant_aware|xx%/xx%| xx | [下载链接]() |
Note: The `_vd` suffix indicates that the pre-trained model uses Mixup. Please refer to the detailed introduction: [mixup: Beyond Empirical Risk Minimization](https://arxiv.org/abs/1710.09412)
### 1.2 剪裁
### 1.4 NAS
| 模型 | 压缩方法 | Top-1/Top-5 Acc | 模型体积(MB) | GFLOPs | 下载 | | Model | Method | Top-1/Top-5 Acc | Volume(MB) | GFLOPs | Download |
|:--:|:---:|:--:|:--:|:--:|:--:| |:--:|:---:|:--:|:--:|:--:|:--:|
| MobileNetV1 | Baseline | 70.99%/89.68% | 17 | 1.11 | [下载链接](http://paddle-imagenet-models-name.bj.bcebos.com/MobileNetV1_pretrained.tar) | | MobileNetV2 | - | 72.15%/90.65% | 15 | 0.59 | [model](https://paddle-imagenet-models-name.bj.bcebos.com/MobileNetV2_pretrained.tar) |
| MobileNetV1 | uniform -50% | 69.4%/88.66% (-1.59%/-1.02%) | 9 | 0.56 | [下载链接](https://paddlemodels.bj.bcebos.com/PaddleSlim/MobileNetV1_uniform-50.tar) | | MobileNetV2_NAS | SANAS | 71.518%/90.208% (-0.632%/-0.442%) | 14 | 0.295 | [model](https://paddlemodels.cdn.bcebos.com/PaddleSlim/MobileNetV2_sanas.tar) |
| MobileNetV1 | sensitive -30% | 70.4%/89.3% (-0.59%/-0.38%) | 12 | 0.74 | [下载链接](https://paddlemodels.bj.bcebos.com/PaddleSlim/MobileNetV1_sensitive-30.tar) |
| MobileNetV1 | sensitive -50% | 69.8% / 88.9% (-1.19%/-0.78%) | 9 | 0.56 | [下载链接](https://paddlemodels.bj.bcebos.com/PaddleSlim/MobileNetV1_sensitive-50.tar) |
| MobileNetV2 | - | 72.15%/90.65% | 15 | 0.59 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/MobileNetV2_pretrained.tar) |
| MobileNetV2 | uniform -50% | 65.79%/86.11% (-6.35%/-4.47%) | 11 | 0.296 | [下载链接](https://paddlemodels.bj.bcebos.com/PaddleSlim/MobileNetV2_uniform-50.tar) |
| ResNet34 | - | 72.15%/90.65% | 84 | 7.36 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/ResNet34_pretrained.tar) |
| ResNet34 | uniform -50% | 70.99%/89.95% (-1.36%/-0.87%) | 41 | 3.67 | [下载链接](https://paddlemodels.bj.bcebos.com/PaddleSlim/ResNet34_uniform-50.tar) |
| ResNet34 | auto -55.05% | 70.24%/89.63% (-2.04%/-1.06%) | 33 | 3.31 | [下载链接](https://paddlemodels.bj.bcebos.com/PaddleSlim/ResNet34_auto-55.tar) |
Dataset: Cifar10
| Model | Method | Acc | Params(MB) | Download |
|:---:|:--:|:--:|:--:|:--:|
| Darts | - | 97.135% | 3.767 | - |
| Darts_SA(Based on Darts) | SANAS | 97.276%(+0.141%) | 3.344(-11.2%) | - |
Note: The token of MobileNetV2_NAS is [4, 4, 5, 1, 1, 2, 1, 1, 0, 2, 6, 2, 0, 3, 4, 5, 0, 4, 5, 5, 1, 4, 8, 0, 0]. The token of Darts_SA is [5, 5, 0, 5, 5, 10, 7, 7, 5, 7, 7, 11, 10, 12, 10, 0, 5, 3, 10, 8].
### 1.3 蒸馏 ## 2. Object Detection
| 模型 | 压缩方法 | Top-1/Top-5 Acc | 模型体积(MB) | 下载 | ### 2.1 Quantization
|:--:|:---:|:--:|:--:|:--:|
| MobileNetV1 | student | 70.99%/89.68% | 17 | [下载链接](http://paddle-imagenet-models-name.bj.bcebos.com/MobileNetV1_pretrained.tar) | Dataset: COCO 2017
|ResNet50_vd|teacher|79.12%/94.44%| 99 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/ResNet50_vd_pretrained.tar) |
|MobileNetV1|ResNet50_vd<sup>[1](#trans1)</sup> distill|72.77%/90.68% (+1.78%/+1.00%)| 17 | [下载链接](https://paddlemodels.bj.bcebos.com/PaddleSlim/MobileNetV1_distilled.tar) | | Model | Method | Dataset | Image/GPU | Input 608 Box AP | Input 416 Box AP | Input 320 Box AP | Model Size(MB) | TensorRT latency(V100, ms) | Download |
| MobileNetV2 | student | 72.15%/90.65% | 15 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/MobileNetV2_pretrained.tar) | | :----------------------------: | :---------: | :----: | :-------: | :------------: | :------------: | :------------: | :------------: | :----------: |:----------: |
| MobileNetV2 | ResNet50_vd distill | 74.28%/91.53% (+2.13%/+0.88%) | 15 | [下载链接](https://paddlemodels.bj.bcebos.com/PaddleSlim/MobileNetV2_distilled.tar) | | MobileNet-V1-YOLOv3 | - | COCO | 8 | 29.3 | 29.3 | 27.1 | 95 | - | [model](https://paddlemodels.bj.bcebos.com/object_detection/yolov3_mobilenet_v1.tar) |
| ResNet50 | student | 76.50%/93.00% | 99 | [下载链接](http://paddle-imagenet-models-name.bj.bcebos.com/ResNet50_pretrained.tar) | | MobileNet-V1-YOLOv3 | quant_post | COCO | 8 | 27.9 (-1.4)| 28.0 (-1.3) | 26.0 (-1.0) | 25 | - | [model](https://paddlemodels.bj.bcebos.com/PaddleSlim/yolov3_mobilenetv1_coco_quant_post.tar) |
|ResNet101|teacher|77.56%/93.64%| 173 | [下载链接](http://paddle-imagenet-models-name.bj.bcebos.com/ResNet101_pretrained.tar) | | MobileNet-V1-YOLOv3 | quant_aware | COCO | 8 | 28.1 (-1.2)| 28.2 (-1.1) | 25.8 (-1.2) | 26.3 | - | [model](https://paddlemodels.bj.bcebos.com/PaddleSlim/yolov3_mobilenet_coco_quant_aware.tar) |
| ResNet50 | ResNet101 distill | 77.29%/93.65% (+0.79%/+0.65%) | 99 | [下载链接](https://paddlemodels.bj.bcebos.com/PaddleSlim/ResNet50_distilled.tar) | | R34-YOLOv3 | - | COCO | 8 | 36.2 | 34.3 | 31.4 | 162 | - | [model](https://paddlemodels.bj.bcebos.com/object_detection/yolov3_r34.tar) |
| R34-YOLOv3 | quant_post | COCO | 8 | 35.7 (-0.5) | - | - | 42.7 | - | [model](https://paddlemodels.bj.bcebos.com/PaddleSlim/yolov3_r34_coco_quant_post.tar) |
| R34-YOLOv3 | quant_aware | COCO | 8 | 35.2 (-1.0) | 33.3 (-1.0) | 30.3 (-1.1)| 44 | - | [model](https://paddlemodels.bj.bcebos.com/PaddleSlim/yolov3_r34_coco_quant_aware.tar) |
| R50-dcn-YOLOv3 obj365_pretrain | - | COCO | 8 | 41.4 | - | - | 177 | 18.56 |[model](https://paddlemodels.bj.bcebos.com/object_detection/yolov3_r50vd_dcn_obj365_pretrained_coco.tar) |
| R50-dcn-YOLOv3 obj365_pretrain | quant_aware | COCO | 8 | 40.6 (-0.8) | 37.5 | 34.1 | 66 | 14.64 | [model](https://paddlemodels.bj.bcebos.com/PaddleSlim/yolov3_r50vd_dcn_obj365_pretrained_coco_quant_aware.tar) |
Dataset:WIDER-FACE
| Model | Method | Image/GPU | Input Size | Easy/Medium/Hard | Model Size(MB) | Download |
| :------------: | :---------: | :-------: | :--------: | :-----------------------------: | :--------------: | :----------------------------------------------------------: |
| BlazeFace | - | 8 | 640 | 91.5/89.2/79.7 | 815 | [model](https://paddlemodels.bj.bcebos.com/object_detection/blazeface_original.tar) |
| BlazeFace | quant_post | 8 | 640 | 87.8/85.1/74.9 (-3.7/-4.1/-4.8) | 228 | [model](https://paddlemodels.bj.bcebos.com/PaddleSlim/blazeface_origin_quant_post.tar) |
| BlazeFace | quant_aware | 8 | 640 | 90.5/87.9/77.6 (-1.0/-1.3/-2.1) | 228 | [model](https://paddlemodels.bj.bcebos.com/PaddleSlim/blazeface_origin_quant_aware.tar) |
| BlazeFace-Lite | - | 8 | 640 | 90.9/88.5/78.1 | 711 | [model](https://paddlemodels.bj.bcebos.com/object_detection/blazeface_lite.tar) |
| BlazeFace-Lite | quant_post | 8 | 640 | 89.4/86.7/75.7 (-1.5/-1.8/-2.4) | 211 | [model]((https://paddlemodels.bj.bcebos.com/PaddleSlim/blazeface_lite_quant_post.tar)) |
| BlazeFace-Lite | quant_aware | 8 | 640 | 89.7/87.3/77.0 (-1.2/-1.2/-1.1) | 211 | [model](https://paddlemodels.bj.bcebos.com/PaddleSlim/blazeface_lite_quant_aware.tar) |
| BlazeFace-NAS | - | 8 | 640 | 83.7/80.7/65.8 | 244 | [model](https://paddlemodels.bj.bcebos.com/object_detection/blazeface_nas.tar) |
| BlazeFace-NAS | quant_post | 8 | 640 | 81.6/78.3/63.6 (-2.1/-2.4/-2.2) | 71 | [model](https://paddlemodels.bj.bcebos.com/PaddleSlim/blazeface_nas_quant_post.tar) |
| BlazeFace-NAS | quant_aware | 8 | 640 | 83.1/79.7/64.2 (-0.6/-1.0/-1.6) | 71 | [model](https://paddlemodels.bj.bcebos.com/PaddleSlim/blazeface_nas_quant_aware.tar) |
### 2.2 Pruning
Dataset:Pasacl VOC & COCO 2017
PaddleLite:
env: Qualcomm SnapDragon 845 + armv8
!!! note "Note" criterion: time cost in Thread1/Thread2/Thread4
<a name="trans1">[1]</a>:带_vd后缀代表该预训练模型使用了Mixup,Mixup相关介绍参考[mixup: Beyond Empirical Risk Minimization](https://arxiv.org/abs/1710.09412) PaddleLite version: v2.3
| Model | Method | Dataset | Image/GPU | Input 608 Box AP | Input 416 Box AP | Input 320 Box AP | Model Size(MB) | GFLOPs (608*608) | PaddleLite cost(ms)(608*608) | TensorRT speed(FPS)(608*608) | Download |
| :----------------------------: | :---------------: | :--------: | :-------: | :--------------: | :--------------: | :--------------: | :------------: | :--------------: | :--------------: | :--------------: | :----------------------------: |
| MobileNet-V1-YOLOv3 | Baseline | Pascal VOC | 8 | 76.2 | 76.7 | 75.3 | 94 | 40.49 | 1238\796.943\520.101 |60.40| [model](https://paddlemodels.bj.bcebos.com/object_detection/yolov3_mobilenet_v1_voc.tar) |
| MobileNet-V1-YOLOv3 | sensitive -52.88% | Pascal VOC | 8 | 77.6 (+1.4) | 77.7 (1.0) | 75.5 (+0.2) | 31 | 19.08 | 602.497\353.759\222.427 |99.36| [model](https://paddlemodels.bj.bcebos.com/PaddleSlim/yolov3_mobilenet_v1_voc_prune.tar) |
| MobileNet-V1-YOLOv3 | - | COCO | 8 | 29.3 | 29.3 | 27.0 | 95 | 41.35 |-|-| [model](https://paddlemodels.bj.bcebos.com/object_detection/yolov3_mobilenet_v1.tar) |
| MobileNet-V1-YOLOv3 | sensitive -51.77% | COCO | 8 | 26.0 (-3.3) | 25.1 (-4.2) | 22.6 (-4.4) | 32 | 19.94 |-|73.93| [model](https://paddlemodels.bj.bcebos.com/PaddleSlim/yolov3_mobilenet_v1_prune.tar) |
| R50-dcn-YOLOv3 | - | COCO | 8 | 39.1 | - | - | 177 | 89.60 |-|27.68| [model](https://paddlemodels.bj.bcebos.com/object_detection/yolov3_r50vd_dcn.tar) |
| R50-dcn-YOLOv3 | sensitive -9.37% | COCO | 8 | 39.3 (+0.2) | - | - | 150 | 81.20 |-|30.08| [model](https://paddlemodels.bj.bcebos.com/PaddleSlim/yolov3_r50vd_dcn_prune.tar) |
| R50-dcn-YOLOv3 | sensitive -24.68% | COCO | 8 | 37.3 (-1.8) | - | - | 113 | 67.48 |-|34.32| [model](https://paddlemodels.bj.bcebos.com/PaddleSlim/yolov3_r50vd_dcn_prune578.tar) |
| R50-dcn-YOLOv3 obj365_pretrain | - | COCO | 8 | 41.4 | - | - | 177 | 89.60 |-|-| [model](https://paddlemodels.bj.bcebos.com/object_detection/yolov3_r50vd_dcn_obj365_pretrained_coco.tar) |
| R50-dcn-YOLOv3 obj365_pretrain | sensitive -9.37% | COCO | 8 | 40.5 (-0.9) | - | - | 150 | 81.20 |-|-| [model](https://paddlemodels.bj.bcebos.com/PaddleSlim/yolov3_r50vd_dcn_obj365_pretrained_coco_prune.tar) |
| R50-dcn-YOLOv3 obj365_pretrain | sensitive -24.68% | COCO | 8 | 37.8 (-3.3) | - | - | 113 | 67.48 |-|-| [model](https://paddlemodels.bj.bcebos.com/PaddleSlim/yolov3_r50vd_dcn_obj365_pretrained_coco_prune578.tar) |
## 2. 目标检测 ### 2.3 Distillation
### 2.1 量化 Dataset:Pasacl VOC & COCO 2017
数据集: COCO 2017
| 模型 | 压缩方法 | 数据集 | Image/GPU | 输入608 Box AP | 输入416 Box AP | 输入320 Box AP | 模型体积(MB) | 下载 | | Model | Method | Dataset | Image/GPU | Input 608 Box AP | Input 416 Box AP | Input 320 Box AP | Model Size(MB) | Download |
| :----------------------------: | :---------: | :----: | :-------: | :------------: | :------------: | :------------: | :------------: | :----------: | | :-----------------: | :---------------------: | :--------: | :-------: | :--------------: | :--------------: | :--------------: | :--------------: | :----------------------------------------------------------: |
| MobileNet-V1-YOLOv3 | - | COCO | 8 | 29.3 | 29.3 | 27.1 | xx | [下载链接]() | | MobileNet-V1-YOLOv3 | - | Pascal VOC | 8 | 76.2 | 76.7 | 75.3 | 94 | [model](https://paddlemodels.bj.bcebos.com/object_detection/yolov3_mobilenet_v1_voc.tar) |
| MobileNet-V1-YOLOv3 | quant_post | COCO | 8 | xx | xx | xx | xx | [下载链接]() | | ResNet34-YOLOv3 | - | Pascal VOC | 8 | 82.6 | 81.9 | 80.1 | 162 | [model](https://paddlemodels.bj.bcebos.com/object_detection/yolov3_r34_voc.tar) |
| MobileNet-V1-YOLOv3 | quant_aware | COCO | 8 | xx | xx | xx | xx | [下载链接]() | | MobileNet-V1-YOLOv3 | ResNet34-YOLOv3 distill | Pascal VOC | 8 | 79.0 (+2.8) | 78.2 (+1.5) | 75.5 (+0.2) | 94 | [model](https://paddlemodels.bj.bcebos.com/PaddleSlim/yolov3_mobilenetv1_voc_distilled.tar) |
| R50-dcn-YOLOv3 obj365_pretrain | - | COCO | 8 | 41.4 | xx | xx | xx | [下载链接]() | | MobileNet-V1-YOLOv3 | - | COCO | 8 | 29.3 | 29.3 | 27.0 | 95 | [model](https://paddlemodels.bj.bcebos.com/object_detection/yolov3_mobilenet_v1.tar) |
| R50-dcn-YOLOv3 obj365_pretrain | quant_post | COCO | 8 | xx | xx | xx | xx | [下载链接]() | | ResNet34-YOLOv3 | - | COCO | 8 | 36.2 | 34.3 | 31.4 | 163 | [model](https://paddlemodels.bj.bcebos.com/object_detection/yolov3_r34.tar) |
| R50-dcn-YOLOv3 obj365_pretrain | quant_aware | COCO | 8 | xx | xx | xx | xx | [下载链接]() | | MobileNet-V1-YOLOv3 | ResNet34-YOLOv3 distill | COCO | 8 | 31.4 (+2.1) | 30.0 (+0.7) | 27.1 (+0.1) | 95 | [model](https://paddlemodels.bj.bcebos.com/PaddleSlim/yolov3_mobilenetv1_coco_distilled.tar) |
### 2.4 NAS
数据集:WIDER-FACE Dataset: WIDER-FACE
| Model | Method | Image/GPU | Input size | Easy/Medium/Hard | volume(KB) | latency(ms)| Download |
| :------------: | :---------: | :-------: | :------: | :-----------------------------: | :------------: | :------------: | :----------------------------------------------------------: |
| BlazeFace | - | 8 | 640 | 91.5/89.2/79.7 | 815 | 71.862 | [model](https://paddlemodels.bj.bcebos.com/object_detection/blazeface_original.tar) |
| BlazeFace-NAS | - | 8 | 640 | 83.7/80.7/65.8 | 244 | 21.117 |[model](https://paddlemodels.bj.bcebos.com/object_detection/blazeface_nas.tar) |
| BlazeFace-NASV2 | SANAS | 8 | 640 | 87.0/83.7/68.5 | 389 | 22.558 | [model](https://paddlemodels.bj.bcebos.com/object_detection/blazeface_nas2.tar) |
Note: latency is based on latency_855.txt, the file is test on 855 by PaddleLite。The config of BlazeFace-NASV2 is in [there](https://github.com/PaddlePaddle/PaddleDetection/blob/master/configs/face_detection/blazeface_nas_v2.yml).
| 模型 | 压缩方法 | Image/GPU | 输入尺寸 | Easy/Medium/Hard | 模型体积(MB) | 下载 | ## 3. Image Segmentation
| :------------: | :---------: | :-------: | :------: | :---------------: | :------------: | :----------: | Dataset:Cityscapes
| BlazeFace | - | 8 | 640 | 0.915/0.892/0.797 | xx | [下载链接]() |
| BlazeFace | quant_post | 8 | 640 | xx/xx/xx | xx | [下载链接]() |
| BlazeFace | quant_aware | 8 | 640 | xx/xx/xx | xx | [下载链接]() |
| BlazeFace-Lite | - | 8 | 640 | 0.909/0.885/0.781 | xx | [下载链接]() |
| BlazeFace-Lite | quant_post | 8 | 640 | xx/xx/xx | xx | [下载链接]() |
| BlazeFace-Lite | quant_aware | 8 | 640 | xx/xx/xx | xx | [下载链接]() |
| BlazeFace-NAS | - | 8 | 640 | 0.837/0.807/0.658 | xx | [下载链接]() |
| BlazeFace-NAS | quant_post | 8 | 640 | xx/xx/xx | xx | [下载链接]() |
| BlazeFace-NAS | quant_aware | 8 | 640 | xx/xx/xx | xx | [下载链接]() |
### 2.2 剪裁 ### 3.1 Quantization
数据集:Pasacl VOC & COCO 2017 | Model | Method | mIoU | Model Size(MB) | Download |
| :--------------------: | :---------: | :-----------: | :--------------: | :----------------------------------------------------------: |
| DeepLabv3+/MobileNetv1 | - | 63.26 | 6.6 | [model](https://paddlemodels.bj.bcebos.com/PaddleSlim/deeplabv3_mobilenetv1.tar ) |
| DeepLabv3+/MobileNetv1 | quant_post | 58.63 (-4.63) | 1.8 | [model](https://paddlemodels.bj.bcebos.com/PaddleSlim/deeplabv3_mobilenetv1_2049x1025_quant_post.tar) |
| DeepLabv3+/MobileNetv1 | quant_aware | 62.03 (-1.23) | 1.8 | [model](https://paddlemodels.bj.bcebos.com/PaddleSlim/deeplabv3_mobilenetv1_2049x1025_quant_aware.tar) |
| DeepLabv3+/MobileNetv2 | - | 69.81 | 7.4 | [model](https://paddleseg.bj.bcebos.com/models/mobilenet_cityscapes.tgz) |
| DeepLabv3+/MobileNetv2 | quant_post | 67.59 (-2.22) | 2.1 | [model](https://paddlemodels.bj.bcebos.com/PaddleSlim/deeplabv3_mobilenetv2_2049x1025_quant_post.tar) |
| DeepLabv3+/MobileNetv2 | quant_aware | 68.33 (-1.48) | 2.1 | [model](https://paddlemodels.bj.bcebos.com/PaddleSlim/deeplabv3_mobilenetv2_2049x1025_quant_aware.tar) |
| 模型 | 压缩方法 | 数据集 | Image/GPU | 输入608 Box AP | 输入416 Box AP | 输入320 Box AP | 模型体积(MB) | GFLOPs (608*608) | 下载 | Image segmentation model PaddleLite latency (ms), input size 769x769
| :----------------------------: | :---------------: | :--------: | :-------: | :------------: | :------------: | :------------: | :----------: | :--------------: | :----------------------------------------------------------: |
| MobileNet-V1-YOLOv3 | Baseline | Pascal VOC | 8 | 76.2 | 76.7 | 75.3 | 94 | 40.49 | [下载链接](https://paddlemodels.bj.bcebos.com/object_detection/yolov3_mobilenet_v1_voc.tar) |
| MobileNet-V1-YOLOv3 | sensitive -52.88% | Pascal VOC | 8 | 77.6 (+1.4) | 77.7 (1.0) | 75.5 (+0.2) | 31 | 19.08 | [下载链接](https://paddlemodels.bj.bcebos.com/PaddleSlim/yolov3_mobilenet_v1_voc_prune.tar) |
| MobileNet-V1-YOLOv3 | - | COCO | 8 | 29.3 | 29.3 | 27.0 | 95 | 41.35 | [下载链接](https://paddlemodels.bj.bcebos.com/object_detection/yolov3_mobilenet_v1.tar) |
| MobileNet-V1-YOLOv3 | sensitive -51.77% | COCO | 8 | 26.0 (-3.3) | 25.1 (-4.2) | 22.6 (-4.4) | 32 | 19.94 | [下载链接](https://paddlemodels.bj.bcebos.com/PaddleSlim/yolov3_mobilenet_v1_prune.tar) |
| R50-dcn-YOLOv3 | - | COCO | 8 | 39.1 | - | - | 177 | 89.60 | [下载链接](https://paddlemodels.bj.bcebos.com/object_detection/yolov3_r50vd_dcn.tar) |
| R50-dcn-YOLOv3 | sensitive -9.37% | COCO | 8 | 39.3 (+0.2) | - | - | 150 | 81.20 | [下载链接](https://paddlemodels.bj.bcebos.com/PaddleSlim/yolov3_r50vd_dcn_prune.tar) |
| R50-dcn-YOLOv3 | sensitive -24.68% | COCO | 8 | 37.3 (-1.8) | - | - | 113 | 67.48 | [下载链接](https://paddlemodels.bj.bcebos.com/PaddleSlim/yolov3_r50vd_dcn_prune578.tar) |
| R50-dcn-YOLOv3 obj365_pretrain | - | COCO | 8 | 41.4 | - | - | 177 | 89.60 | [下载链接](https://paddlemodels.bj.bcebos.com/object_detection/yolov3_r50vd_dcn_obj365_pretrained_coco.tar) |
| R50-dcn-YOLOv3 obj365_pretrain | sensitive -9.37% | COCO | 8 | 40.5 (-0.9) | - | - | 150 | 81.20 | [下载链接](https://paddlemodels.bj.bcebos.com/PaddleSlim/yolov3_r50vd_dcn_obj365_pretrained_coco_prune.tar) |
| R50-dcn-YOLOv3 obj365_pretrain | sensitive -24.68% | COCO | 8 | 37.8 (-3.3) | - | - | 113 | 67.48 | [下载链接](https://paddlemodels.bj.bcebos.com/PaddleSlim/yolov3_r50vd_dcn_obj365_pretrained_coco_prune578.tar) |
### 2.3 蒸馏 | Device | Model | Method | armv7 Thread 1 | armv7 Thread 2 | armv7 Thread 4 | armv8 Thread 1 | armv8 Thread 2 | armv8 Thread 4 |
| ------------ | ---------------------- | ------------- | -------------- | -------------- | -------------- | -------------- | -------------- | -------------- |
| Qualcomm 835 | Deeplabv3- MobileNetV1 | FP32 baseline | 1227.9894 | 734.1922 | 527.9592 | 1109.96 | 699.3818 | 479.0818 |
| Qualcomm 835 | Deeplabv3- MobileNetV1 | quant_aware | 848.6544 | 512.785 | 382.9915 | 752.3573 | 455.0901 | 307.8808 |
| Qualcomm 835 | Deeplabv3- MobileNetV1 | quant_post | 840.2323 | 510.103 | 371.9315 | 748.9401 | 452.1745 | 309.2084 |
| Qualcomm 835 | Deeplabv3-MobileNetV2 | FP32 baseline | 1282.8126 | 793.2064 | 653.6538 | 1193.9908 | 737.1827 | 593.4522 |
| Qualcomm 835 | Deeplabv3-MobileNetV2 | quant_aware | 976.0495 | 659.0541 | 513.4279 | 892.1468 | 582.9847 | 484.7512 |
| Qualcomm 835 | Deeplabv3-MobileNetV2 | quant_post | 981.44 | 658.4969 | 538.6166 | 885.3273 | 586.1284 | 484.0018 |
| Qualcomm 855 | Deeplabv3- MobileNetV1 | FP32 baseline | 568.8748 | 339.8578 | 278.6316 | 420.6031 | 281.3197 | 217.5222 |
| Qualcomm 855 | Deeplabv3- MobileNetV1 | quant_aware | 608.7578 | 347.2087 | 260.653 | 241.2394 | 177.3456 | 143.9178 |
| Qualcomm 855 | Deeplabv3- MobileNetV1 | quant_post | 609.0142 | 347.3784 | 259.9825 | 239.4103 | 180.1894 | 139.9178 |
| Qualcomm 855 | Deeplabv3-MobileNetV2 | FP32 baseline | 639.4425 | 390.1851 | 322.7014 | 477.7667 | 339.7411 | 262.2847 |
| Qualcomm 855 | Deeplabv3-MobileNetV2 | quant_aware | 703.7275 | 497.689 | 417.1296 | 394.3586 | 300.2503 | 239.9204 |
| Qualcomm 855 | Deeplabv3-MobileNetV2 | quant_post | 705.7589 | 474.4076 | 427.2951 | 394.8352 | 297.4035 | 264.6724 |
| Kirin 970 | Deeplabv3- MobileNetV1 | FP32 baseline | 1682.1792 | 1437.9774 | 1181.0246 | 1261.6739 | 1068.6537 | 690.8225 |
| Kirin 970 | Deeplabv3- MobileNetV1 | quant_aware | 1062.3394 | 1248.1014 | 878.3157 | 774.6356 | 710.6277 | 528.5376 |
| Kirin 970 | Deeplabv3- MobileNetV1 | quant_post | 1109.1917 | 1339.6218 | 866.3587 | 771.5164 | 716.5255 | 500.6497 |
| Kirin 970 | Deeplabv3-MobileNetV2 | FP32 baseline | 1771.1301 | 1746.0569 | 1222.4805 | 1448.9739 | 1192.4491 | 760.606 |
| Kirin 970 | Deeplabv3-MobileNetV2 | quant_aware | 1320.2905 | 921.4522 | 676.0732 | 1145.8801 | 821.5685 | 590.1713 |
| Kirin 970 | Deeplabv3-MobileNetV2 | quant_post | 1320.386 | 918.5328 | 672.2481 | 1020.753 | 820.094 | 591.4114 |
数据集:Pasacl VOC & COCO 2017
| 模型 | 压缩方法 | 数据集 | Image/GPU | 输入608 Box AP | 输入416 Box AP | 输入320 Box AP | 模型体积(MB) | 下载 |
| :-----------------: | :---------------------: | :--------: | :-------: | :------------: | :------------: | :------------: | :------------: | :----------------------------------------------------------: |
| MobileNet-V1-YOLOv3 | - | Pascal VOC | 8 | 76.2 | 76.7 | 75.3 | 94 | [下载链接](https://paddlemodels.bj.bcebos.com/object_detection/yolov3_mobilenet_v1_voc.tar) |
| ResNet34-YOLOv3 | - | Pascal VOC | 8 | 82.6 | 81.9 | 80.1 | 162 | [下载链接](https://paddlemodels.bj.bcebos.com/object_detection/yolov3_r34_voc.tar) |
| MobileNet-V1-YOLOv3 | ResNet34-YOLOv3 distill | Pascal VOC | 8 | 79.0 (+2.8) | 78.2 (+1.5) | 75.5 (+0.2) | 94 | [下载链接](https://paddlemodels.bj.bcebos.com/PaddleSlim/yolov3_mobilenetv1_voc_distilled.tar) |
| MobileNet-V1-YOLOv3 | - | COCO | 8 | 29.3 | 29.3 | 27.0 | 95 | [下载链接](https://paddlemodels.bj.bcebos.com/object_detection/yolov3_mobilenet_v1.tar) |
| ResNet34-YOLOv3 | - | COCO | 8 | 36.2 | 34.3 | 31.4 | 163 | [下载链接](https://paddlemodels.bj.bcebos.com/object_detection/yolov3_r34.tar) |
| MobileNet-V1-YOLOv3 | ResNet34-YOLOv3 distill | COCO | 8 | 31.4 (+2.1) | 30.0 (+0.7) | 27.1 (+0.1) | 95 | [下载链接](https://paddlemodels.bj.bcebos.com/PaddleSlim/yolov3_mobilenetv1_coco_distilled.tar) |
## 3. 图像分割 ### 3.2 Pruning
数据集:Cityscapes PaddleLite:
### 3.1 量化 env: Qualcomm SnapDragon 845 + armv8
| 模型 | 压缩方法 | mIoU | 模型体积(MB) | 下载 | criterion: time cost in Thread1/Thread2/Thread4
| :--------------------: | :---------: | :---: | :------------: | :----------: |
| DeepLabv3+/MobileNetv1 | - | 63.26 | xx | [下载链接]() |
| DeepLabv3+/MobileNetv1 | quant_post | xx | xx | [下载链接]() |
| DeepLabv3+/MobileNetv1 | quant_aware | xx | xx | [下载链接]() |
| DeepLabv3+/MobileNetv2 | - | 69.81 | xx | [下载链接]() |
| DeepLabv3+/MobileNetv2 | quant_post | xx | xx | [下载链接]() |
| DeepLabv3+/MobileNetv2 | quant_aware | xx | xx | [下载链接]() |
### 3.2 剪裁 PaddleLite version: v2.3
| 模型 | 压缩方法 | mIoU | 模型体积(MB) | GFLOPs | 下载 | | Model | Method | mIoU | Model Size(MB) | GFLOPs | PaddleLite cost(ms) | TensorRT speed(FPS) | Download |
| :-------: | :---------------: | :-----------: | :------------: | :----: | :----------------------------------------------------------: | | :-------: | :---------------: | :-----------: | :--------------: | :----: | :--------------: | :----: | :-------------------: |
| fast-scnn | baseline | 69.64 | 11 | 14.41 | [下载链接](https://paddlemodels.bj.bcebos.com/PaddleSlim/fast_scnn_cityscape.tar) | | fast-scnn | baseline | 69.64 | 11 | 14.41 | 1226.36\682.96\415.664 |39.53| [model](https://paddlemodels.bj.bcebos.com/PaddleSlim/fast_scnn_cityscape.tar) |
| fast-scnn | uniform -17.07% | 69.58 (-0.06) | 8.5 | 11.95 | [下载链接](https://paddlemodels.bj.bcebos.com/PaddleSlim/fast_scnn_cityscape_uniform-17.tar) | | fast-scnn | uniform -17.07% | 69.58 (-0.06) | 8.5 | 11.95 | 1140.37\656.612\415.888 |42.01| [model](https://paddlemodels.bj.bcebos.com/PaddleSlim/fast_scnn_cityscape_uniform-17.tar) |
| fast-scnn | sensitive -47.60% | 66.68 (-2.96) | 5.7 | 7.55 | [下载链接](https://paddlemodels.bj.bcebos.com/PaddleSlim/fast_scnn_cityscape_sensitive-47.tar) | | fast-scnn | sensitive -47.60% | 66.68 (-2.96) | 5.7 | 7.55 | 866.693\494.467\291.748 |51.48| [model](https://paddlemodels.bj.bcebos.com/PaddleSlim/fast_scnn_cityscape_sensitive-47.tar) |
# SANAS进阶版实验教程-压缩DARTS产出模型
## 收益情况
利用DARTS搜索出来的最终模型结构(以下简称为DARTS_model)构造相应的搜索空间,根据PaddleSlim提供的SANAS搜索方法进行搜索实验,最终得到的模型结构(以下简称为DARTS_SA)相比DARTS_model的精度提升<font color=green>0.141%</font>,模型大小下降<font color=green>11.2%</font>。
## 搜索教程
本教程展示了如何在DARTS_model基础上利用SANAS进行搜索实验,并得到DARTS_SA的结果。
本教程包含以下步骤:
1. 构造搜索空间
2. 导入依赖包并定义全局变量
3. 初始化SANAS实例
4. 定义计算模型参数量的函数
5. 定义网络输入数据的函数
6. 定义造program的函数
7. 定义训练函数
8. 定义预测函数
9. 启动搜索
9.1 获取下一个模型结构
9.2 构造相应的训练和预测program
9.3 添加搜索限制
9.4 定义环境
9.5 定义输入数据
9.6 启动训练和评估
9.7 回传当前模型的得分reward
10. 利用demo下的脚本启动搜索
11. 利用demo下的脚本启动最终实验
### 1. 构造搜索空间
进行搜索实验之前,首先需要根据DARTS_model的模型特点构造相应的搜索空间,本次实验仅会对DARTS_model的通道数进行搜索,搜索的目的是得到一个精度更高并且模型参数更少的模型。
定义如下搜索空间:
- 通道数`filter_num`: 定义了每个卷积操作的通道数变化区间。取值区间为:`[4, 8, 12, 16, 20, 36, 54, 72, 90, 108, 144, 180, 216, 252]`
按照通道数来区分DARTS_model中block的话,则DARTS_model中共有3个block,第一个block仅包含6个normal cell,之后的两个block每个block都包含和一个reduction cell和6个normal cell,共有20个cell。在构造搜索空间的时候我们定义每个cell中的所有卷积操作都使用相同的通道数,共有20位token。
完整的搜索空间可以参考[基于DARTS_model的搜索空间](../../../paddleslim/nas/search_space/darts_space.py)
### 2. 引入依赖包并定义全局变量
```python
import numpy as np
import paddle
import paddle.fluid as fluid
from paddleslim.nas import SANAS
BATCH_SIZE=96
SERVER_ADDRESS = ""
PORT = 8377
SEARCH_STEPS = 300
RETAIN_EPOCH=30
MAX_PARAMS=3.77
IMAGE_SHAPE=[3, 32, 32]
AUXILIARY = True
AUXILIARY_WEIGHT= 0.4
TRAINSET_NUM = 50000
LR = 0.025
MOMENTUM = 0.9
WEIGHT_DECAY = 0.0003
DROP_PATH_PROBILITY = 0.2
```
### 3. 初始化SANAS实例
首先需要初始化SANAS示例。
```python
config = [('DartsSpace')]
sa_nas = SANAS(config, server_addr=(SERVER_ADDRESS, PORT), search_steps=SEARCH_STEPS, is_server=True)
```
### 4. 定义计算模型参数量的函数
根据输入的program计算当前模型中的参数量。本教程使用模型参数量作为搜索的限制条件。
```python
def count_parameters_in_MB(all_params, prefix='model'):
parameters_number = 0
for param in all_params:
if param.name.startswith(
prefix) and param.trainable and 'aux' not in param.name:
parameters_number += np.prod(param.shape)
return parameters_number / 1e6
```
### 5. 定义网络输入数据的函数
根据输入图片的尺寸定义网络中的输入,其中包括图片输入、标签输入和在训练过程中需要随机丢弃单元的比例和掩膜。
```python
def create_data_loader(IMAGE_SHAPE, is_train):
image = fluid.data(
name="image", shape=[None] + IMAGE_SHAPE, dtype="float32")
label = fluid.data(name="label", shape=[None, 1], dtype="int64")
data_loader = fluid.io.DataLoader.from_generator(
feed_list=[image, label],
capacity=64,
use_double_buffer=True,
iterable=True)
drop_path_prob = ''
drop_path_mask = ''
if is_train:
drop_path_prob = fluid.data(
name="drop_path_prob", shape=[BATCH_SIZE, 1], dtype="float32")
drop_path_mask = fluid.data(
name="drop_path_mask",
shape=[BATCH_SIZE, 20, 4, 2],
dtype="float32")
return data_loader, image, label, drop_path_prob, drop_path_mask
```
### 6. 定义构造program的函数
根据输入的模型结构、输入图片尺寸和当前program是否是训练模式构造program。
```python
def build_program(main_program, startup_program, IMAGE_SHAPE, archs, is_train):
with fluid.program_guard(main_program, startup_program):
data_loader, data, label, drop_path_prob, drop_path_mask = create_data_loader(
IMAGE_SHAPE, is_train)
logits, logits_aux = archs(data, drop_path_prob, drop_path_mask,
is_train, 10)
top1 = fluid.layers.accuracy(input=logits, label=label, k=1)
top5 = fluid.layers.accuracy(input=logits, label=label, k=5)
loss = fluid.layers.reduce_mean(
fluid.layers.softmax_with_cross_entropy(logits, label))
if is_train:
if AUXILIARY:
loss_aux = fluid.layers.reduce_mean(
fluid.layers.softmax_with_cross_entropy(logits_aux, label))
loss = loss + AUXILIARY_WEIGHT * loss_aux
step_per_epoch = int(TRAINSET_NUM / BATCH_SIZE)
learning_rate = fluid.layers.cosine_decay(LR, step_per_epoch, RETAIN_EPOCH)
fluid.clip.set_gradient_clip(
clip=fluid.clip.GradientClipByGlobalNorm(clip_norm=5.0))
optimizer = fluid.optimizer.MomentumOptimizer(
learning_rate,
MOMENTUM,
regularization=fluid.regularizer.L2DecayRegularizer(
WEIGHT_DECAY))
optimizer.minimize(loss)
outs = [loss, top1, top5, learning_rate]
else:
outs = [loss, top1, top5]
return outs, data_loader
```
### 7. 定义训练函数
```python
def train(main_prog, exe, epoch_id, train_loader, fetch_list):
loss = []
top1 = []
top5 = []
for step_id, data in enumerate(train_loader()):
devices_num = len(data)
if DROP_PATH_PROBILITY > 0:
feed = []
for device_id in range(devices_num):
image = data[device_id]['image']
label = data[device_id]['label']
drop_path_prob = np.array(
[[DROP_PATH_PROBILITY * epoch_id / RETAIN_EPOCH]
for i in range(BATCH_SIZE)]).astype(np.float32)
drop_path_mask = 1 - np.random.binomial(
1, drop_path_prob[0],
size=[BATCH_SIZE, 20, 4, 2]).astype(np.float32)
feed.append({
"image": image,
"label": label,
"drop_path_prob": drop_path_prob,
"drop_path_mask": drop_path_mask
})
else:
feed = data
loss_v, top1_v, top5_v, lr = exe.run(
main_prog, feed=feed, fetch_list=[v.name for v in fetch_list])
loss.append(loss_v)
top1.append(top1_v)
top5.append(top5_v)
if step_id % 10 == 0:
print(
"Train Epoch {}, Step {}, Lr {:.8f}, loss {:.6f}, acc_1 {:.6f}, acc_5 {:.6f}".
format(epoch_id, step_id, lr[0], np.mean(loss), np.mean(top1), np.mean(top5)))
return np.mean(top1)
```
### 8. 定义预测函数
```python
def valid(main_prog, exe, epoch_id, valid_loader, fetch_list):
loss = []
top1 = []
top5 = []
for step_id, data in enumerate(valid_loader()):
loss_v, top1_v, top5_v = exe.run(
main_prog, feed=data, fetch_list=[v.name for v in fetch_list])
loss.append(loss_v)
top1.append(top1_v)
top5.append(top5_v)
if step_id % 10 == 0:
print(
"Valid Epoch {}, Step {}, loss {:.6f}, acc_1 {:.6f}, acc_5 {:.6f}".
format(epoch_id, step_id, np.mean(loss), np.mean(top1), np.mean(top5)))
return np.mean(top1)
```
### 9. 启动搜索实验
以下步骤拆解说明了如何获得当前模型结构以及获得当前模型结构之后应该有的步骤。
#### 9.1 获取下一个模型结构
根据上面的SANAS实例中的函数获取下一个模型结构。
```python
archs = sa_nas.next_archs()[0]
```
#### 9.2 构造训练和预测program
根据上一步中获得的模型结构分别构造训练program和预测program。
```python
train_program = fluid.Program()
test_program = fluid.Program()
startup_program = fluid.Program()
train_fetch_list, train_loader = build_program(train_program, startup_program, IMAGE_SHAPE, archs, is_train=True)
test_fetch_list, test_loader = build_program(test_program, startup_program, IMAGE_SHAPE, archs, is_train=False)
test_program = test_program.clone(for_test=True)
```
#### 9.3 添加搜索限制
本教程以模型参数量为限制条件。首先计算一下当前program的参数量,如果超出限制条件,则终止本次模型结构的训练,获取下一个模型结构。
```python
current_params = count_parameters_in_MB(
train_program.global_block().all_parameters(), 'cifar10')
```
#### 9.4 定义环境
定义数据和模型的环境并初始化参数。
```python
place = fluid.CPUPlace()
exe = fluid.Executor(place)
exe.run(startup_program)
```
#### 9.5 定义输入数据
由于本示例中对cifar10中的图片进行了一些额外的预处理操作,和[快速开始](../quick_start/nas_tutorial.md)示例中的reader不同,所以需要自定义cifar10的reader,不能直接调用paddle中封装好的`paddle.dataset.cifar10`的reader。自定义cifar10的reader文件位于[demo/nas](../../../demo/nas/darts_cifar10_reader.py)中。
**注意:**本示例为了简化代码直接调用`paddle.dataset.cifar10`定义训练数据和预测数据,实际训练需要使用自定义cifar10的reader。
```python
train_reader = paddle.batch(paddle.reader.shuffle(paddle.dataset.cifar.train10(cycle=False), buf_size=1024), batch_size=BATCH_SIZE, drop_last=True)
test_reader = paddle.batch(paddle.dataset.cifar.test10(cycle=False), batch_size=BATCH_SIZE, drop_last=False)
train_loader.set_sample_list_generator(train_reader, places=place)
test_loader.set_sample_list_generator(test_reader, places=place)
```
#### 9.6 启动训练和评估
```python
for epoch_id in range(RETAIN_EPOCH):
train_top1 = train(train_program, exe, epoch_id, train_loader, train_fetch_list)
print("TRAIN: Epoch {}, train_acc {:.6f}".format(epoch_id, train_top1))
valid_top1 = valid(test_program, exe, epoch_id, test_loader, test_fetch_list)
print("TEST: Epoch {}, valid_acc {:.6f}".format(epoch_id, valid_top1))
valid_top1_list.append(valid_top1)
```
#### 9.7 回传当前模型的得分reward
本教程利用最后两个epoch的准确率均值作为最终的得分回传给SANAS。
```python
sa_nas.reward(float(valid_top1_list[-1] + valid_top1_list[-2]) / 2)
```
### 10. 利用demo下的脚本启动搜索
搜索文件位于: [darts_sanas_demo](https://github.com/PaddlePaddle/PaddleSlim/tree/develop/demo/nas/darts_nas.py),搜索过程中限制模型参数量为不大于3.77M。
```python
cd demo/nas/
python darts_nas.py
```
### 11. 利用demo下的脚本启动最终实验
最终实验文件位于: [darts_sanas_demo](https://github.com/PaddlePaddle/PaddleSlim/tree/develop/demo/nas/darts_nas.py),最终实验需要训练600epoch。以下示例输入token为`[5, 5, 0, 5, 5, 10, 7, 7, 5, 7, 7, 11, 10, 12, 10, 0, 5, 3, 10, 8]`。
```python
cd demo/nas/
python darts_nas.py --token 5 5 0 5 5 10 7 7 5 7 7 11 10 12 10 0 5 3 10 8 --retain_epoch 600
```
# Pruning of image classification model - sensitivity
In this tutorial, you will learn how to use [sensitivity API of PaddleSlim](https://paddlepaddle.github.io/PaddleSlim/api/prune_api/#sensitivity) by a demo of MobileNetV1 model on MNIST dataset。
This tutorial following workflow:
1. Import dependency
2. Build model
3. Define data reader
4. Define function for test
5. Training model
6. Get names of parameter
7. Compute sensitivities
8. Pruning model
## 1. Import dependency
PaddleSlim dependents on Paddle1.7. Please ensure that you have installed paddle correctly. Import Paddle and PaddleSlim as below:
```python
import paddle
import paddle.fluid as fluid
import paddleslim as slim
```
## 2. Build model
This section will build a classsification model based `MobileNetV1` for MNIST task. The shape of the input is `[1, 28, 28]` and the output number is 10.
To make the code simple, we define a function in package `paddleslim.models` to build classification model.
Excute following code to build a model,
```python
exe, train_program, val_program, inputs, outputs = slim.models.image_classification("MobileNet", [1, 28, 28], 10, use_gpu=True)
place = fluid.CUDAPlace(0)
```
>Note:The functions in paddleslim.models is just used in tutorials or demos.
## 3 Define data reader
MNIST dataset is used for making the demo can be executed quickly. It defines some functions for downloading and reading MNIST dataset in package `paddle.dataset.mnist`.
Show as below:
```python
import paddle.dataset.mnist as reader
train_reader = paddle.batch(
reader.train(), batch_size=128, drop_last=True)
test_reader = paddle.batch(
reader.test(), batch_size=128, drop_last=True)
data_feeder = fluid.DataFeeder(inputs, place)
```
## 4. Define test function
To get the performance of model on test dataset after pruning a convolution layer, we define a test function as below:
```python
import numpy as np
def test(program):
acc_top1_ns = []
acc_top5_ns = []
for data in test_reader():
acc_top1_n, acc_top5_n, _ = exe.run(
program,
feed=data_feeder.feed(data),
fetch_list=outputs)
acc_top1_ns.append(np.mean(acc_top1_n))
acc_top5_ns.append(np.mean(acc_top5_n))
print("Final eva - acc_top1: {}; acc_top5: {}".format(
np.mean(np.array(acc_top1_ns)), np.mean(np.array(acc_top5_ns))))
return np.mean(np.array(acc_top1_ns))
```
## 5. Training model
Sensitivity analysis is dependent on pretrained model. So we should train the model defined in section 2 for some epochs. One epoch training is enough for this simple demo while more epochs may be necessary for other model. Or you can load pretrained model from filesystem.
Training model as below:
```python
for data in train_reader():
acc1, acc5, loss = exe.run(train_program, feed=data_feeder.feed(data), fetch_list=outputs)
print(np.mean(acc1), np.mean(acc5), np.mean(loss))
```
Get the performance using the test function defined in section 4:
```python
test(val_program)
```
## 6. Get names of parameters
```python
params = []
for param in train_program.global_block().all_parameters():
if "_sep_weights" in param.name:
params.append(param.name)
print(params)
params = params[:5]
```
## 7. Compute sensitivities
### 7.1 Compute in single process
Apply sensitivity analysis on pretrained model by calling [sensitivity API](https://paddlepaddle.github.io/PaddleSlim/api/prune_api/#sensitivity).
The sensitivities will be appended into the file given by option `sensitivities_file` during computing.
The information in this file won`t be computed repeatedly.
Remove the file `sensitivities_0.data` in current directory:
```python
!rm -rf sensitivities_0.data
```
Apart from the parameters to be analyzed, it also support for setting the ratios that each convolutoin will be pruned.
If one model losses 90% accuracy on test dataset when its single convolution layer is pruned by 40%, then we can set `pruned_ratios` to `[0.1, 0.2, 0.3, 0.4]`.
The granularity of `pruned_ratios` should be small to get more reasonable sensitivities. But small granularity of `pruned_ratios` will slow down the computing.
```python
sens_0 = slim.prune.sensitivity(
val_program,
place,
params,
test,
sensitivities_file="sensitivities_0.data",
pruned_ratios=[0.1, 0.2])
print(sens_0)
```
### 7.2 Expand sensitivities
We can expand `pruned_ratios` to `[0.1, 0.2, 0.3]` based the sensitivities generated in section 7.1.
```python
sens_0 = slim.prune.sensitivity(
val_program,
place,
params,
test,
sensitivities_file="sensitivities_0.data",
pruned_ratios=[0.3])
print(sens_0)
```
### 7.3 Computing sensitivity in multi-process
The time cost of computing sensitivities is dependent on the count of parameters and the speed of model evaluation on test dataset. We can speed up computing by multi-process.
Split `pruned_ratios` into multi-process, and merge the sensitivities from multi-process.
#### 7.3.1 Computing in each process
We have compute the sensitivities when `pruned_ratios=[0.1, 0.2, 0.3]` and saved the sensitivities into file named `sensitivities_0.data`.
在另一个进程中,The we start a task by setting `pruned_ratios=[0.4]` in another process and save result into file named `sensitivities_1.data`. Show as below:
```python
sens_1 = slim.prune.sensitivity(
val_program,
place,
params,
test,
sensitivities_file="sensitivities_1.data",
pruned_ratios=[0.4])
print(sens_1)
```
#### 7.3.2 Load sensitivity file generated in multi-process
```python
s_0 = slim.prune.load_sensitivities("sensitivities_0.data")
s_1 = slim.prune.load_sensitivities("sensitivities_1.data")
print(s_0)
print(s_1)
```
#### 7.3.3 Merge sensitivies
```python
s = slim.prune.merge_sensitive([s_0, s_1])
print(s)
```
## 8. Pruning model
Pruning model according to the sensitivities generated in section 7.3.3.
### 8.1 Get pruning ratios
Get a group of ratios by calling [get_ratios_by_loss](https://paddlepaddle.github.io/PaddleSlim/api/prune_api/#get_ratios_by_loss) fuction:
```python
loss = 0.01
ratios = slim.prune.get_ratios_by_loss(s_0, loss)
print(ratios)
```
### 8.2 Pruning training network
```python
pruner = slim.prune.Pruner()
print("FLOPs before pruning: {}".format(slim.analysis.flops(train_program)))
pruned_program, _, _ = pruner.prune(
train_program,
fluid.global_scope(),
params=ratios.keys(),
ratios=ratios.values(),
place=place)
print("FLOPs after pruning: {}".format(slim.analysis.flops(pruned_program)))
```
### 8.3 Pruning test network
Note:The `only_graph` should be set to True while pruning test network. [Pruner API](https://paddlepaddle.github.io/PaddleSlim/api/prune_api/#pruner)
```python
pruner = slim.prune.Pruner()
print("FLOPs before pruning: {}".format(slim.analysis.flops(val_program)))
pruned_val_program, _, _ = pruner.prune(
val_program,
fluid.global_scope(),
params=ratios.keys(),
ratios=ratios.values(),
place=place,
only_graph=True)
print("FLOPs after pruning: {}".format(slim.analysis.flops(pruned_val_program)))
```
Get accuracy of pruned model on test dataset:
```python
test(pruned_val_program)
```
### 8.4 Training pruned model
Training pruned model:
```python
for data in train_reader():
acc1, acc5, loss = exe.run(pruned_program, feed=data_feeder.feed(data), fetch_list=outputs)
print(np.mean(acc1), np.mean(acc5), np.mean(loss))
```
Get accuracy of model after training:
```python
test(pruned_val_program)
```
...@@ -3,9 +3,13 @@ ...@@ -3,9 +3,13 @@
======== ========
.. toctree:: .. toctree::
:maxdepth: 2 :maxdepth: 1
:caption: Contents:
image_classification_sensitivity_analysis_tutorial.md image_classification_sensitivity_analysis_tutorial.md
image_classification_nas_quick_start.ipynb darts_nas_turorial.md
paddledetection_slim_distillation_tutorial.md
paddledetection_slim_nas_tutorial.md
paddledetection_slim_pruing_tutorial.md
paddledetection_slim_prune_dist_tutorial.md
paddledetection_slim_quantization_tutorial.md
paddledetection_slim_sensitivy_tutorial.md
...@@ -4,5 +4,5 @@ Aadvanced Tutorials ...@@ -4,5 +4,5 @@ Aadvanced Tutorials
.. toctree:: .. toctree::
:maxdepth: 1 :maxdepth: 1
sensitivity_tutorial_en.md image_classification_sensitivity_analysis_tutorial_en.md
# 目标检测模型蒸馏教程
教程内容请参考:https://github.com/PaddlePaddle/PaddleDetection/blob/release/0.2/slim/distillation/README.md
## 示例结果
### MobileNetV1-YOLO-V3-VOC
| FLOPS |输入尺寸|每张GPU图片个数|推理时间(fps)|Box AP|下载|
|:-:|:-:|:-:|:-:|:-:|:-:|
|baseline|608 |16|104.291|76.2|[下载链接](https://paddlemodels.bj.bcebos.com/object_detection/yolov3_mobilenet_v1_voc.tar)|
|蒸馏后|608 |16|106.914|79.0|[下载链接](https://paddlemodels.bj.bcebos.com/PaddleSlim/yolov3_mobilenetv1_voc_distilled.tar)|
|baseline|416 |16|-|76.7|[下载链接](https://paddlemodels.bj.bcebos.com/object_detection/yolov3_mobilenet_v1_voc.tar)|
|蒸馏后|416 |16|-|78.2|[下载链接](https://paddlemodels.bj.bcebos.com/PaddleSlim/yolov3_mobilenetv1_voc_distilled.tar)|
|baseline|320 |16|-|75.3|[下载链接](https://paddlemodels.bj.bcebos.com/object_detection/yolov3_mobilenet_v1_voc.tar)|
|蒸馏后|320 |16|-|75.5|[下载链接](https://paddlemodels.bj.bcebos.com/PaddleSlim/yolov3_mobilenetv1_voc_distilled.tar)|
> 蒸馏后的结果用ResNet34-YOLO-V3做teacher,4GPU总batch_size64训练90000 iter得到
### MobileNetV1-YOLO-V3-COCO
| FLOPS |输入尺寸|每张GPU图片个数|推理时间(fps)|Box AP|下载|
|:-:|:-:|:-:|:-:|:-:|:-:|
|baseline|608 |16|78.302|29.3|[下载链接](https://paddlemodels.bj.bcebos.com/object_detection/yolov3_mobilenet_v1_voc.tar)|
|蒸馏后|608 |16|78.523|31.4|[下载链接](https://paddlemodels.bj.bcebos.com/PaddleSlim/yolov3_mobilenetv1_coco_distilled.tar)|
|baseline|416 |16|-|29.3|[下载链接](https://paddlemodels.bj.bcebos.com/object_detection/yolov3_mobilenet_v1_voc.tar)|
|蒸馏后|416 |16|-|30.0|[下载链接](https://paddlemodels.bj.bcebos.com/PaddleSlim/yolov3_mobilenetv1_coco_distilled.tar)|
|baseline|320 |16|-|27.0|[下载链接](https://paddlemodels.bj.bcebos.com/object_detection/yolov3_mobilenet_v1_voc.tar)|
|蒸馏后|320 |16|-|27.1|[下载链接](https://paddlemodels.bj.bcebos.com/PaddleSlim/yolov3_mobilenetv1_coco_distilled.tar)|
> 蒸馏后的结果用ResNet34-YOLO-V3做teacher,4GPU总batch_size64训练600000 iter得到
# 人脸检测模型小模型结构搜索教程
教程内容请参考:https://github.com/PaddlePaddle/PaddleDetection/blob/release/0.2/slim/nas/README.md
## 概述
我们选取人脸检测的BlazeFace模型作为神经网络搜索示例,该示例使用PaddleSlim 辅助完成神经网络搜索实验。
基于PaddleSlim进行搜索实验过程中,搜索限制条件可以选择是浮点运算数(FLOPs)限制还是硬件延时(latency)限制,硬件延时限制需要提供延时表。本示例提供一份基于blazeface搜索空间的硬件延时表,名称是latency_855.txt(基于PaddleLite在骁龙855上测试的延时),可以直接用该表进行blazeface的硬件延时搜索实验。
# 目标检测模型卷积通道剪裁教程
请参考:https://github.com/PaddlePaddle/PaddleDetection/blob/release/0.2/slim/prune/README.md
# 目标检测模型蒸馏剪裁教程
教程内容请参考:https://github.com/PaddlePaddle/PaddleDetection/blob/release/0.2/slim/extensions/distill_pruned_model/README.md
## 概述
该文档介绍如何使用PaddleSlim的蒸馏接口和卷积通道剪裁接口对检测库中的模型进行卷积层的通道剪裁并使用较高精度模型对其蒸馏。
# 目标检测模型定点量化教程
教程内容请参考:https://github.com/PaddlePaddle/PaddleDetection/blob/release/0.2/slim/quantization/README.md
## 示例结果
### 训练策略
- 量化策略`post`为使用离线量化得到的模型,`aware`为在线量化训练得到的模型。
### YOLOv3 on COCO
| 骨架网络 | 预训练权重 | 量化策略 | 输入尺寸 | Box AP | 下载 |
| :----------------| :--------: | :------: | :------: |:------: | :-----------------------------------------------------: |
| MobileNetV1 | ImageNet | post | 608 | 27.9 | [下载链接](https://paddlemodels.bj.bcebos.com/PaddleSlim/yolov3_mobilenetv1_coco_quant_post.tar) |
| MobileNetV1 | ImageNet | post | 416 | 28.0 | [下载链接](https://paddlemodels.bj.bcebos.com/PaddleSlim/yolov3_mobilenetv1_coco_quant_post.tar) |
| MobileNetV1 | ImageNet | post | 320 | 26.0 | [下载链接](https://paddlemodels.bj.bcebos.com/PaddleSlim/yolov3_mobilenetv1_coco_quant_post.tar) |
| MobileNetV1 | ImageNet | aware | 608 | 28.1 | [下载链接](https://paddlemodels.bj.bcebos.com/PaddleSlim/yolov3_mobilenetv1_coco_quant_aware.tar) |
| MobileNetV1 | ImageNet | aware | 416 | 28.2 | [下载链接](https://paddlemodels.bj.bcebos.com/PaddleSlim/yolov3_mobilenetv1_coco_quant_aware.tar) |
| MobileNetV1 | ImageNet | aware | 320 | 25.8 | [下载链接](https://paddlemodels.bj.bcebos.com/PaddleSlim/yolov3_mobilenetv1_coco_quant_aware.tar) |
| ResNet34 | ImageNet | post | 608 | 35.7 | [下载链接](https://paddlemodels.bj.bcebos.com/PaddleSlim/yolov3_r34_coco_quant_post.tar) |
| ResNet34 | ImageNet | aware | 608 | 35.2 | [下载链接](https://paddlemodels.bj.bcebos.com/PaddleSlim/yolov3_r34_coco_quant_aware.tar) |
| ResNet34 | ImageNet | aware | 416 | 33.3 | [下载链接](https://paddlemodels.bj.bcebos.com/PaddleSlim/yolov3_r34_coco_quant_aware.tar) |
| ResNet34 | ImageNet | aware | 320 | 30.3 | [下载链接](https://paddlemodels.bj.bcebos.com/PaddleSlim/yolov3_r34_coco_quant_aware.tar) |
| R50vd-dcn | object365 | aware | 608 | 40.6 | [下载链接](https://paddlemodels.bj.bcebos.com/PaddleSlim/yolov3_r50vd_dcn_obj365_pretrained_coco_quant_aware.tar) |
| R50vd-dcn | object365 | aware | 416 | 37.5 | [下载链接](https://paddlemodels.bj.bcebos.com/PaddleSlim/yolov3_r50vd_dcn_obj365_pretrained_coco_quant_aware.tar) |
| R50vd-dcn | object365 | aware | 320 | 34.1 | [下载链接](https://paddlemodels.bj.bcebos.com/PaddleSlim/yolov3_r50vd_dcn_obj365_pretrained_coco_quant_aware.tar) |
# 目标检测模型敏感度分析教程
教程内容请参考:https://github.com/PaddlePaddle/PaddleDetection/blob/release/0.2/slim/sensitive/README.md
...@@ -81,7 +81,7 @@ ...@@ -81,7 +81,7 @@
<ul class="current"> <ul class="current">
<li class="toctree-l1"><a class="reference internal" href="../index_en.html">English Documents</a></li> <li class="toctree-l1"><a class="reference internal" href="../index_en.html">English Documents</a></li>
<li class="toctree-l1"><a class="reference internal" href="../intro.html">PaddleSlim简介</a></li> <li class="toctree-l1"><a class="reference internal" href="../intro.html">介绍</a></li>
<li class="toctree-l1"><a class="reference internal" href="../install.html">安装</a></li> <li class="toctree-l1"><a class="reference internal" href="../install.html">安装</a></li>
<li class="toctree-l1"><a class="reference internal" href="../quick_start/index.html">快速开始</a></li> <li class="toctree-l1"><a class="reference internal" href="../quick_start/index.html">快速开始</a></li>
<li class="toctree-l1"><a class="reference internal" href="../tutorials/index.html">进阶教程</a></li> <li class="toctree-l1"><a class="reference internal" href="../tutorials/index.html">进阶教程</a></li>
...@@ -90,39 +90,39 @@ ...@@ -90,39 +90,39 @@
<li class="toctree-l1 current"><a class="current reference internal" href="#">算法原理</a><ul> <li class="toctree-l1 current"><a class="current reference internal" href="#">算法原理</a><ul>
<li class="toctree-l2"><a class="reference internal" href="#id2">目录</a></li> <li class="toctree-l2"><a class="reference internal" href="#id2">目录</a></li>
<li class="toctree-l2"><a class="reference internal" href="#quantization-aware-training">1. Quantization Aware Training量化介绍</a><ul> <li class="toctree-l2"><a class="reference internal" href="#quantization-aware-training">1. Quantization Aware Training量化介绍</a><ul>
<li class="toctree-l3"><a class="reference internal" href="#id3">1.1 背景</a></li> <li class="toctree-l3"><a class="reference internal" href="#id7">1.1 背景</a></li>
<li class="toctree-l3"><a class="reference internal" href="#id4">1.2 量化原理</a><ul> <li class="toctree-l3"><a class="reference internal" href="#id8">1.2 量化原理</a><ul>
<li class="toctree-l4"><a class="reference internal" href="#id5">1.2.1 量化方式</a></li> <li class="toctree-l4"><a class="reference internal" href="#id9">1.2.1 量化方式</a></li>
<li class="toctree-l4"><a class="reference internal" href="#id6">1.2.2 量化训练</a></li> <li class="toctree-l4"><a class="reference internal" href="#id10">1.2.2 量化训练</a></li>
<li class="toctree-l4"><a class="reference internal" href="#id10">1.2.4 训练后量化</a></li> <li class="toctree-l4"><a class="reference internal" href="#id14">1.2.4 训练后量化</a></li>
</ul> </ul>
</li> </li>
</ul> </ul>
</li> </li>
<li class="toctree-l2"><a class="reference internal" href="#id11">2. 卷积核剪裁原理</a><ul> <li class="toctree-l2"><a class="reference internal" href="#id15">2. 卷积核剪裁原理</a><ul>
<li class="toctree-l3"><a class="reference internal" href="#id12">2.1 剪裁卷积核</a></li> <li class="toctree-l3"><a class="reference internal" href="#id16">2.1 剪裁卷积核</a></li>
<li class="toctree-l3"><a class="reference internal" href="#uniform">2.2 Uniform剪裁卷积网络</a></li> <li class="toctree-l3"><a class="reference internal" href="#uniform">2.2 Uniform剪裁卷积网络</a></li>
<li class="toctree-l3"><a class="reference internal" href="#id13">2.3 基于敏感度剪裁卷积网络</a><ul> <li class="toctree-l3"><a class="reference internal" href="#id17">2.3 基于敏感度剪裁卷积网络</a><ul>
<li class="toctree-l4"><a class="reference internal" href="#id14">两个假设</a></li> <li class="toctree-l4"><a class="reference internal" href="#id18">两个假设</a></li>
<li class="toctree-l4"><a class="reference internal" href="#filter">剪裁filter的指导原则</a></li> <li class="toctree-l4"><a class="reference internal" href="#filter">剪裁filter的指导原则</a></li>
<li class="toctree-l4"><a class="reference internal" href="#id15">敏感度的理解</a></li> <li class="toctree-l4"><a class="reference internal" href="#id19">敏感度的理解</a></li>
<li class="toctree-l4"><a class="reference internal" href="#id16">选择最优的剪裁率组合</a></li> <li class="toctree-l4"><a class="reference internal" href="#id20">选择最优的剪裁率组合</a></li>
<li class="toctree-l4"><a class="reference internal" href="#id17">迭代剪裁</a></li> <li class="toctree-l4"><a class="reference internal" href="#id21">迭代剪裁</a></li>
</ul> </ul>
</li> </li>
</ul> </ul>
</li> </li>
<li class="toctree-l2"><a class="reference internal" href="#id18">3. 蒸馏</a></li> <li class="toctree-l2"><a class="reference internal" href="#id22">3. 蒸馏</a></li>
<li class="toctree-l2"><a class="reference internal" href="#id19">4. 轻量级模型结构搜索</a><ul> <li class="toctree-l2"><a class="reference internal" href="#id25">4. 轻量级模型结构搜索</a><ul>
<li class="toctree-l3"><a class="reference internal" href="#id20">4.1 搜索策略</a><ul> <li class="toctree-l3"><a class="reference internal" href="#id26">4.1 搜索策略</a><ul>
<li class="toctree-l4"><a class="reference internal" href="#id21">4.1.1 模拟退火</a></li> <li class="toctree-l4"><a class="reference internal" href="#id27">4.1.1 模拟退火</a></li>
</ul> </ul>
</li> </li>
<li class="toctree-l3"><a class="reference internal" href="#id22">4.2 搜索空间</a></li> <li class="toctree-l3"><a class="reference internal" href="#id28">4.2 搜索空间</a></li>
<li class="toctree-l3"><a class="reference internal" href="#id23">4.3 模型延时评估</a></li> <li class="toctree-l3"><a class="reference internal" href="#id29">4.3 模型延时评估</a></li>
</ul> </ul>
</li> </li>
<li class="toctree-l2"><a class="reference internal" href="#id24">5. 参考文献</a></li> <li class="toctree-l2"><a class="reference internal" href="#id30">5. 参考文献</a></li>
</ul> </ul>
</li> </li>
</ul> </ul>
...@@ -174,16 +174,16 @@ ...@@ -174,16 +174,16 @@
<div class="section" id="id2"> <div class="section" id="id2">
<h2>目录<a class="headerlink" href="#id2" title="永久链接至标题"></a></h2> <h2>目录<a class="headerlink" href="#id2" title="永久链接至标题"></a></h2>
<ul class="simple"> <ul class="simple">
<li><a class="reference external" href="#1-quantization-aware-training%E9%87%8F%E5%8C%96%E4%BB%8B%E7%BB%8D">量化原理介绍</a></li> <li><a class="reference external" href="#1-quantization-aware-training量化介绍">量化原理介绍</a></li>
<li><a class="reference external" href="#2-%E5%8D%B7%E7%A7%AF%E6%A0%B8%E5%89%AA%E8%A3%81%E5%8E%9F%E7%90%86">剪裁原理介绍</a></li> <li><a class="reference external" href="#2-卷积核剪裁原理">剪裁原理介绍</a></li>
<li><a class="reference external" href="#3-%E8%92%B8%E9%A6%8F">蒸馏原理介绍</a></li> <li><a class="reference external" href="#3-蒸馏">蒸馏原理介绍</a></li>
<li><a class="reference external" href="#4-%E8%BD%BB%E9%87%8F%E7%BA%A7%E6%A8%A1%E5%9E%8B%E7%BB%93%E6%9E%84%E6%90%9C%E7%B4%A2">轻量级模型结构搜索原理介绍</a></li> <li><a class="reference external" href="#4-轻量级模型结构搜索">轻量级模型结构搜索原理介绍</a></li>
</ul> </ul>
</div> </div>
<div class="section" id="quantization-aware-training"> <div class="section" id="quantization-aware-training">
<h2>1. Quantization Aware Training量化介绍<a class="headerlink" href="#quantization-aware-training" title="永久链接至标题"></a></h2> <h2>1. Quantization Aware Training量化介绍<a class="headerlink" href="#quantization-aware-training" title="永久链接至标题"></a></h2>
<div class="section" id="id3"> <div class="section" id="id7">
<h3>1.1 背景<a class="headerlink" href="#id3" title="永久链接至标题"></a></h3> <h3>1.1 背景<a class="headerlink" href="#id7" title="永久链接至标题"></a></h3>
<p>近年来,定点量化使用更少的比特数(如8-bit、3-bit、2-bit等)表示神经网络的权重和激活已被验证是有效的。定点量化的优点包括低内存带宽、低功耗、低计算资源占用以及低模型存储需求等。</p> <p>近年来,定点量化使用更少的比特数(如8-bit、3-bit、2-bit等)表示神经网络的权重和激活已被验证是有效的。定点量化的优点包括低内存带宽、低功耗、低计算资源占用以及低模型存储需求等。</p>
<p align="center"> <p align="center">
<img src="https://raw.githubusercontent.com/PaddlePaddle/PaddleSlim/develop/docs/docs/images/algo/quan_table_0.png" height=258 width=600 hspace='10'/> <br /> <img src="https://raw.githubusercontent.com/PaddlePaddle/PaddleSlim/develop/docs/docs/images/algo/quan_table_0.png" height=258 width=600 hspace='10'/> <br />
...@@ -194,64 +194,62 @@ ...@@ -194,64 +194,62 @@
<strong>表2:模型量化前后精度对比</strong> <strong>表2:模型量化前后精度对比</strong>
</p><p>目前,学术界主要将量化分为两大类:<code class="docutils literal"><span class="pre">Post</span> <span class="pre">Training</span> <span class="pre">Quantization</span></code><code class="docutils literal"><span class="pre">Quantization</span> <span class="pre">Aware</span> <span class="pre">Training</span></code><code class="docutils literal"><span class="pre">Post</span> <span class="pre">Training</span> <span class="pre">Quantization</span></code>是指使用KL散度、滑动平均等方法确定量化参数且不需要重新训练的定点量化方法。<code class="docutils literal"><span class="pre">Quantization</span> <span class="pre">Aware</span> <span class="pre">Training</span></code>是在训练过程中对量化进行建模以确定量化参数,它与<code class="docutils literal"><span class="pre">Post</span> <span class="pre">Training</span> <span class="pre">Quantization</span></code>模式相比可以提供更高的预测精度。</p> </p><p>目前,学术界主要将量化分为两大类:<code class="docutils literal"><span class="pre">Post</span> <span class="pre">Training</span> <span class="pre">Quantization</span></code><code class="docutils literal"><span class="pre">Quantization</span> <span class="pre">Aware</span> <span class="pre">Training</span></code><code class="docutils literal"><span class="pre">Post</span> <span class="pre">Training</span> <span class="pre">Quantization</span></code>是指使用KL散度、滑动平均等方法确定量化参数且不需要重新训练的定点量化方法。<code class="docutils literal"><span class="pre">Quantization</span> <span class="pre">Aware</span> <span class="pre">Training</span></code>是在训练过程中对量化进行建模以确定量化参数,它与<code class="docutils literal"><span class="pre">Post</span> <span class="pre">Training</span> <span class="pre">Quantization</span></code>模式相比可以提供更高的预测精度。</p>
</div> </div>
<div class="section" id="id4"> <div class="section" id="id8">
<h3>1.2 量化原理<a class="headerlink" href="#id4" title="永久链接至标题"></a></h3> <h3>1.2 量化原理<a class="headerlink" href="#id8" title="永久链接至标题"></a></h3>
<div class="section" id="id5"> <div class="section" id="id9">
<h4>1.2.1 量化方式<a class="headerlink" href="#id5" title="永久链接至标题"></a></h4> <h4>1.2.1 量化方式<a class="headerlink" href="#id9" title="永久链接至标题"></a></h4>
<p>目前,存在着许多方法可以将浮点数量化成定点数。例如: <p>目前,存在着许多方法可以将浮点数量化成定点数。例如:
$$ r = min(max(x, a), b)$$ $$ s = \frac{b - a}{n - 1} $$ $$ q = \left \lfloor \frac{r - a}{s} \right \rceil $$ $$ r = min(max(x, a), b)$$ $$ s = frac{b - a}{n - 1} $$ $$ q = left lfloor frac{r - a}{s} right rceil $$
式中,$x$是待量化的浮点值,$[a, b]$是量化范围,$a$是待量化浮点数中的最小值, $b$ 是待量化浮点数中的最大值。$\left \lfloor \right \rceil$ 表示将结果四舍五入到最近的整数。如果量化级别为$k$,则$n$为$2^k$。例如,若$k$为8,则$n$为256。$q$是量化得到的整数。 式中,$x$是待量化的浮点值,$[a, b]$是量化范围,$a$是待量化浮点数中的最小值, $b$ 是待量化浮点数中的最大值。$left lfloor right rceil$ 表示将结果四舍五入到最近的整数。如果量化级别为$k$,则$n$为$2^k$。例如,若$k$为8,则$n$为256。$q$是量化得到的整数。
PaddleSlim框架中选择的量化方法为最大绝对值量化(<code class="docutils literal"><span class="pre">max-abs</span></code>),具体描述如下: PaddleSlim框架中选择的量化方法为最大绝对值量化(<code class="docutils literal"><span class="pre">max-abs</span></code>),具体描述如下:
$$ M = max(abs(x)) $$ $$ q = \left \lfloor \frac{x}{M} * (n - 1) \right \rceil $$ $$ M = max(abs(x)) $$ $$ q = left lfloor frac{x}{M} * (n - 1) right rceil $$
式中,$x$是待被量化的浮点值,$M$是待量化浮点数中的绝对值最大值。$\left \lfloor \right \rceil$表示将结果四舍五入到最近的整数。对于8bit量化,PaddleSlim采用<code class="docutils literal"><span class="pre">int8_t</span></code>,即$n=2^7=128$。$q$是量化得到的整数。 式中,$x$是待被量化的浮点值,$M$是待量化浮点数中的绝对值最大值。$left lfloor right rceil$表示将结果四舍五入到最近的整数。对于8bit量化,PaddleSlim采用<code class="docutils literal"><span class="pre">int8_t</span></code>,即$n=2^7=128$。$q$是量化得到的整数。
无论是<code class="docutils literal"><span class="pre">min-max量化</span></code>还是<code class="docutils literal"><span class="pre">max-abs量化</span></code>,他们都可以表示为如下形式: 无论是<code class="docutils literal"><span class="pre">min-max量化</span></code>还是<code class="docutils literal"><span class="pre">max-abs量化</span></code>,他们都可以表示为如下形式:
$q = scale * r + b$ $q = scale * r + b$
其中<code class="docutils literal"><span class="pre">min-max</span></code><code class="docutils literal"><span class="pre">max-abs</span></code>被称为量化参数或者量化比例或者量化范围。</p> 其中<code class="docutils literal"><span class="pre">min-max</span></code><code class="docutils literal"><span class="pre">max-abs</span></code>被称为量化参数或者量化比例或者量化范围。</p>
</div> </div>
<div class="section" id="id6"> <div class="section" id="id10">
<h4>1.2.2 量化训练<a class="headerlink" href="#id6" title="永久链接至标题"></a></h4> <h4>1.2.2 量化训练<a class="headerlink" href="#id10" title="永久链接至标题"></a></h4>
<div class="section" id="id7"> <div class="section" id="id11">
<h5>1.2.2.1 前向传播<a class="headerlink" href="#id7" title="永久链接至标题"></a></h5> <h5>1.2.2.1 前向传播<a class="headerlink" href="#id11" title="永久链接至标题"></a></h5>
<p>前向传播过程采用模拟量化的方式,具体描述如下:</p> <p>前向传播过程采用模拟量化的方式,具体描述如下:</p>
<p align="center"> <p align="center">
<img src="https://raw.githubusercontent.com/PaddlePaddle/PaddleSlim/develop/docs/docs/images/algo/quan_forward.png" height=433 width=335 hspace='10'/> <br /> <img src="https://raw.githubusercontent.com/PaddlePaddle/PaddleSlim/develop/docs/docs/images/algo/quan_forward.png" height=433 width=335 hspace='10'/> <br />
<strong>图1:基于模拟量化训练的前向过程</strong> <strong>图1:基于模拟量化训练的前向过程</strong>
</p><p>由图1可知,基于模拟量化训练的前向过程可被描述为以下四个部分:</p> </p><p>由图1可知,基于模拟量化训练的前向过程可被描述为以下四个部分:
<ol class="simple"> 1) 输入和权重均被量化成8-bit整数。
<li>输入和权重均被量化成8-bit整数。</li> 2) 在8-bit整数上执行矩阵乘法或者卷积操作。
<li>在8-bit整数上执行矩阵乘法或者卷积操作。</li> 3) 反量化矩阵乘法或者卷积操作的输出结果为32-bit浮点型数据。
<li>反量化矩阵乘法或者卷积操作的输出结果为32-bit浮点型数据。</li> 4) 在32-bit浮点型数据上执行偏置加法操作。此处,偏置并未被量化。
<li>在32-bit浮点型数据上执行偏置加法操作。此处,偏置并未被量化。
对于通用矩阵乘法(<code class="docutils literal"><span class="pre">GEMM</span></code>),输入$X$和权重$W$的量化操作可被表述为如下过程: 对于通用矩阵乘法(<code class="docutils literal"><span class="pre">GEMM</span></code>),输入$X$和权重$W$的量化操作可被表述为如下过程:
$$ X_q = \left \lfloor \frac{X}{X_m} * (n - 1) \right \rceil $$ $$ W_q = \left \lfloor \frac{W}{W_m} * (n - 1) \right \rceil $$ $$ X_q = left lfloor frac{X}{X_m} * (n - 1) right rceil $$ $$ W_q = left lfloor frac{W}{W_m} * (n - 1) right rceil $$
执行通用矩阵乘法: 执行通用矩阵乘法:
$$ Y_q = X_q * W_q $$ $$ Y_q = X_q * W<em>q $$
对量化乘积结果$Yq$进行反量化: 对量化乘积结果$Yq$进行反量化:
$$ $$
\begin{align} begin{align}
Y_{dq} = \frac{Y_q}{(n - 1) * (n - 1)} * X_m * W_m =\frac{X_q * W_q}{(n - 1) * (n - 1)} * X_m * W_m =(\frac{X_q}{n - 1} * X_m) * (\frac{W_q}{n - 1} * W_m) \end{align} Y</em>{dq} = frac{Y_q}{(n - 1) * (n - 1)} * X_m * W_m =frac{X_q * W_q}{(n - 1) * (n - 1)} * X_m * W_m =(frac{X_q}{n - 1} * X_m) * (frac{W_q}{n - 1} * W_m) end{align}
$$ $$
上述公式表明反量化操作可以被移动到<code class="docutils literal"><span class="pre">GEMM</span></code>之前,即先对$Xq$和$Wq$执行反量化操作再做<code class="docutils literal"><span class="pre">GEMM</span></code>操作。因此,前向传播的工作流亦可表示为如下方式:</li> 上述公式表明反量化操作可以被移动到<code class="docutils literal"><span class="pre">GEMM</span></code>之前,即先对$Xq$和$Wq$执行反量化操作再做<code class="docutils literal"><span class="pre">GEMM</span></code>操作。因此,前向传播的工作流亦可表示为如下方式:</p>
</ol>
<p align="center"> <p align="center">
<img src="https://raw.githubusercontent.com/PaddlePaddle/PaddleSlim/develop/docs/docs/images/algo/quan_fwd_1.png" height=435 width=341 hspace='10'/> <br /> <img src="https://raw.githubusercontent.com/PaddlePaddle/PaddleSlim/develop/docs/docs/images/algo/quan_fwd_1.png" height=435 width=341 hspace='10'/> <br />
<strong>图2:基于模拟量化训练前向过程的等价工作流</strong> <strong>图2:基于模拟量化训练前向过程的等价工作流</strong>
</p><p>训练过程中,PaddleSlim使用图2中所示的等价工作流。在设计中,量化Pass在IrGraph中插入量化op和反量化op。因为在连续的量化、反量化操作之后输入仍然为32-bit浮点型数据。因此,PaddleSlim量化训练框架所采用的量化方式被称为模拟量化。</p> </p><p>训练过程中,PaddleSlim使用图2中所示的等价工作流。在设计中,量化Pass在IrGraph中插入量化op和反量化op。因为在连续的量化、反量化操作之后输入仍然为32-bit浮点型数据。因此,PaddleSlim量化训练框架所采用的量化方式被称为模拟量化。</p>
</div> </div>
<div class="section" id="id8"> <div class="section" id="id12">
<h5>1.2.2.2 反向传播<a class="headerlink" href="#id8" title="永久链接至标题"></a></h5> <h5>1.2.2.2 反向传播<a class="headerlink" href="#id12" title="永久链接至标题"></a></h5>
<p>由图3可知,权重更新所需的梯度值可以由量化后的权重和量化后的激活求得。反向传播过程中的所有输入和输出均为32-bit浮点型数据。注意,梯度更新操作需要在原始权重上进行,即计算出的梯度将被加到原始权重上而非量化后或反量化后的权重上。</p> <p>由图3可知,权重更新所需的梯度值可以由量化后的权重和量化后的激活求得。反向传播过程中的所有输入和输出均为32-bit浮点型数据。注意,梯度更新操作需要在原始权重上进行,即计算出的梯度将被加到原始权重上而非量化后或反量化后的权重上。</p>
<p align="center"> <p align="center">
<img src="https://raw.githubusercontent.com/PaddlePaddle/PaddleSlim/develop/docs/docs/images/algo/quan_bwd.png" height=300 width=650 hspace='10'/> <br /> <img src="https://raw.githubusercontent.com/PaddlePaddle/PaddleSlim/develop/docs/docs/images/algo/quan_bwd.png" height=300 width=650 hspace='10'/> <br />
<strong>图3:基于模拟量化训练的反向传播和权重更新过程</strong> <strong>图3:基于模拟量化训练的反向传播和权重更新过程</strong>
</p><p>因此,量化Pass也会改变相应反向算子的某些输入。</p> </p><p>因此,量化Pass也会改变相应反向算子的某些输入。</p>
</div> </div>
<div class="section" id="id9"> <div class="section" id="id13">
<h5>1.2.2.3 确定量化比例系数<a class="headerlink" href="#id9" title="永久链接至标题"></a></h5> <h5>1.2.2.3 确定量化比例系数<a class="headerlink" href="#id13" title="永久链接至标题"></a></h5>
<p>存在着两种策略可以计算求取量化比例系数,即动态策略和静态策略。动态策略会在每次迭代过程中计算量化比例系数的值。静态策略则对不同的输入采用相同的量化比例系数。 <p>存在着两种策略可以计算求取量化比例系数,即动态策略和静态策略。动态策略会在每次迭代过程中计算量化比例系数的值。静态策略则对不同的输入采用相同的量化比例系数。
对于权重而言,在训练过程中采用动态策略。换句话说,在每次迭代过程中量化比例系数均会被重新计算得到直至训练过程结束。 对于权重而言,在训练过程中采用动态策略。换句话说,在每次迭代过程中量化比例系数均会被重新计算得到直至训练过程结束。
对于激活而言,可以选择动态策略也可以选择静态策略。若选择使用静态策略,则量化比例系数会在训练过程中被评估求得,且在推断过程中被使用(不同的输入均保持不变)。静态策略中的量化比例系数可于训练过程中通过如下三种方式进行评估:</p> 对于激活而言,可以选择动态策略也可以选择静态策略。若选择使用静态策略,则量化比例系数会在训练过程中被评估求得,且在推断过程中被使用(不同的输入均保持不变)。静态策略中的量化比例系数可于训练过程中通过如下三种方式进行评估:</p>
<ol class="simple"> <ol class="arabic simple">
<li>在一个窗口中计算激活最大绝对值的平均值。</li> <li>在一个窗口中计算激活最大绝对值的平均值。</li>
<li>在一个窗口中计算激活最大绝对值的最大值。</li> <li>在一个窗口中计算激活最大绝对值的最大值。</li>
<li>在一个窗口中计算激活最大绝对值的滑动平均值,计算公式如下:</li> <li>在一个窗口中计算激活最大绝对值的滑动平均值,计算公式如下:</li>
...@@ -260,8 +258,8 @@ $$ ...@@ -260,8 +258,8 @@ $$
<p>式中,$V$ 是当前batch的最大绝对值, $Vt$是滑动平均值。$k$是一个因子,例如其值可取为0.9。</p> <p>式中,$V$ 是当前batch的最大绝对值, $Vt$是滑动平均值。$k$是一个因子,例如其值可取为0.9。</p>
</div> </div>
</div> </div>
<div class="section" id="id10"> <div class="section" id="id14">
<h4>1.2.4 训练后量化<a class="headerlink" href="#id10" title="永久链接至标题"></a></h4> <h4>1.2.4 训练后量化<a class="headerlink" href="#id14" title="永久链接至标题"></a></h4>
<p>训练后量化是基于采样数据,采用KL散度等方法计算量化比例因子的方法。相比量化训练,训练后量化不需要重新训练,可以快速得到量化模型。</p> <p>训练后量化是基于采样数据,采用KL散度等方法计算量化比例因子的方法。相比量化训练,训练后量化不需要重新训练,可以快速得到量化模型。</p>
<p>训练后量化的目标是求取量化比例因子,主要有两种方法:非饱和量化方法 ( No Saturation) 和饱和量化方法 (Saturation)。非饱和量化方法计算FP32类型Tensor中绝对值的最大值<code class="docutils literal"><span class="pre">abs_max</span></code>,将其映射为127,则量化比例因子等于<code class="docutils literal"><span class="pre">abs_max/127</span></code>。饱和量化方法使用KL散度计算一个合适的阈值<code class="docutils literal"><span class="pre">T</span></code> (<code class="docutils literal"><span class="pre">0&lt;T&lt;mab_max</span></code>),将其映射为127,则量化比例因子等于<code class="docutils literal"><span class="pre">T/127</span></code>。一般而言,对于待量化op的权重Tensor,采用非饱和量化方法,对于待量化op的激活Tensor(包括输入和输出),采用饱和量化方法 。</p> <p>训练后量化的目标是求取量化比例因子,主要有两种方法:非饱和量化方法 ( No Saturation) 和饱和量化方法 (Saturation)。非饱和量化方法计算FP32类型Tensor中绝对值的最大值<code class="docutils literal"><span class="pre">abs_max</span></code>,将其映射为127,则量化比例因子等于<code class="docutils literal"><span class="pre">abs_max/127</span></code>。饱和量化方法使用KL散度计算一个合适的阈值<code class="docutils literal"><span class="pre">T</span></code> (<code class="docutils literal"><span class="pre">0&lt;T&lt;mab_max</span></code>),将其映射为127,则量化比例因子等于<code class="docutils literal"><span class="pre">T/127</span></code>。一般而言,对于待量化op的权重Tensor,采用非饱和量化方法,对于待量化op的激活Tensor(包括输入和输出),采用饱和量化方法 。</p>
<p>训练后量化的实现步骤如下:</p> <p>训练后量化的实现步骤如下:</p>
...@@ -275,19 +273,19 @@ $$ ...@@ -275,19 +273,19 @@ $$
</div> </div>
</div> </div>
</div> </div>
<div class="section" id="id11"> <div class="section" id="id15">
<h2>2. 卷积核剪裁原理<a class="headerlink" href="#id11" title="永久链接至标题"></a></h2> <h2>2. 卷积核剪裁原理<a class="headerlink" href="#id15" title="永久链接至标题"></a></h2>
<p>该策略参考paper: <a class="reference external" href="https://arxiv.org/pdf/1608.08710.pdf">Pruning Filters for Efficient ConvNets</a></p> <p>该策略参考paper: <a class="reference external" href="https://arxiv.org/pdf/1608.08710.pdf">Pruning Filters for Efficient ConvNets</a></p>
<p>该策略通过减少卷积层中卷积核的数量,来减小模型大小和降低模型计算复杂度。</p> <p>该策略通过减少卷积层中卷积核的数量,来减小模型大小和降低模型计算复杂度。</p>
<div class="section" id="id12"> <div class="section" id="id16">
<h3>2.1 剪裁卷积核<a class="headerlink" href="#id12" title="永久链接至标题"></a></h3> <h3>2.1 剪裁卷积核<a class="headerlink" href="#id16" title="永久链接至标题"></a></h3>
<p><strong>剪裁注意事项1</strong> <p><strong>剪裁注意事项1</strong>
剪裁一个conv layer的filter,需要修改后续conv layer的filter. 如<strong>图4</strong>所示,剪掉Xi的一个filter,会导致$X_{i+1}$少一个channel, $X_{i+1}$对应的filter在input_channel纬度上也要减1.</p> 剪裁一个conv layer的filter,需要修改后续conv layer的filter. 如<strong>图4</strong>所示,剪掉Xi的一个filter,会导致$X<em>{i+1}$少一个channel, $X</em>{i+1}$对应的filter在input_channel纬度上也要减1.</p>
<p align="center"> <p align="center">
<img src="https://raw.githubusercontent.com/PaddlePaddle/PaddleSlim/develop/docs/docs/images/algo/pruning_0.png" height=200 width=600 hspace='10'/> <br /> <img src="https://raw.githubusercontent.com/PaddlePaddle/PaddleSlim/develop/docs/docs/images/algo/pruning_0.png" height=200 width=600 hspace='10'/> <br />
<strong>图4</strong> <strong>图4</strong>
</p><p><strong>剪裁注意事项2</strong></p> </p><p><strong>剪裁注意事项2</strong></p>
<p><strong>图5</strong>所示,剪裁完$X_i$之后,根据注意事项1我们从$X_{i+1}$的filter中删除了一行(图中蓝色行),在计算$X_{i+1}$的filters的l1_norm(图中绿色一列)的时候,有两种选择: <p><strong>图5</strong>所示,剪裁完$X<em>i$之后,根据注意事项1我们从$X</em>{i+1}$的filter中删除了一行(图中蓝色行),在计算$X_{i+1}$的filters的l1_norm(图中绿色一列)的时候,有两种选择:
算上被删除的一行:independent pruning 算上被删除的一行:independent pruning
减去被删除的一行:greedy pruning</p> 减去被删除的一行:greedy pruning</p>
<p align="center"> <p align="center">
...@@ -295,7 +293,7 @@ $$ ...@@ -295,7 +293,7 @@ $$
<strong>图5</strong> <strong>图5</strong>
</p><p><strong>剪裁注意事项3</strong> </p><p><strong>剪裁注意事项3</strong>
在对ResNet等复杂网络剪裁的时候,还要考虑到后当前卷积层的修改对上一层卷积层的影响。 在对ResNet等复杂网络剪裁的时候,还要考虑到后当前卷积层的修改对上一层卷积层的影响。
<strong>图6</strong>所示,在对residual block剪裁时,$X_{i+1}$层如何剪裁取决于project shortcut的剪裁结果,因为我们要保证project shortcut的output和$X_{i+1}$的output能被正确的concat.</p> <strong>图6</strong>所示,在对residual block剪裁时,$X<em>{i+1}$层如何剪裁取决于project shortcut的剪裁结果,因为我们要保证project shortcut的output和$X</em>{i+1}$的output能被正确的concat.</p>
<p align="center"> <p align="center">
<img src="https://raw.githubusercontent.com/PaddlePaddle/PaddleSlim/develop/docs/docs/images/algo/pruning_2.png" height=240 width=600 hspace='10'/> <br /> <img src="https://raw.githubusercontent.com/PaddlePaddle/PaddleSlim/develop/docs/docs/images/algo/pruning_2.png" height=240 width=600 hspace='10'/> <br />
<strong>图6</strong> <strong>图6</strong>
...@@ -305,11 +303,11 @@ $$ ...@@ -305,11 +303,11 @@ $$
<p>每层剪裁一样比例的卷积核。 <p>每层剪裁一样比例的卷积核。
在剪裁一个卷积核之前,按l1_norm对filter从高到低排序,越靠后的filter越不重要,优先剪掉靠后的filter.</p> 在剪裁一个卷积核之前,按l1_norm对filter从高到低排序,越靠后的filter越不重要,优先剪掉靠后的filter.</p>
</div> </div>
<div class="section" id="id13"> <div class="section" id="id17">
<h3>2.3 基于敏感度剪裁卷积网络<a class="headerlink" href="#id13" title="永久链接至标题"></a></h3> <h3>2.3 基于敏感度剪裁卷积网络<a class="headerlink" href="#id17" title="永久链接至标题"></a></h3>
<p>根据每个卷积层敏感度的不同,剪掉不同比例的卷积核。</p> <p>根据每个卷积层敏感度的不同,剪掉不同比例的卷积核。</p>
<div class="section" id="id14"> <div class="section" id="id18">
<h4>两个假设<a class="headerlink" href="#id14" title="永久链接至标题"></a></h4> <h4>两个假设<a class="headerlink" href="#id18" title="永久链接至标题"></a></h4>
<ul class="simple"> <ul class="simple">
<li>在一个conv layer的parameter内部,按l1_norm对filter从高到低排序,越靠后的filter越不重要。</li> <li>在一个conv layer的parameter内部,按l1_norm对filter从高到低排序,越靠后的filter越不重要。</li>
<li>两个layer剪裁相同的比例的filters,我们称对模型精度影响更大的layer的敏感度相对高。</li> <li>两个layer剪裁相同的比例的filters,我们称对模型精度影响更大的layer的敏感度相对高。</li>
...@@ -322,24 +320,24 @@ $$ ...@@ -322,24 +320,24 @@ $$
<li>优先剪裁layer内l1_norm相对低的filter</li> <li>优先剪裁layer内l1_norm相对低的filter</li>
</ul> </ul>
</div> </div>
<div class="section" id="id15"> <div class="section" id="id19">
<h4>敏感度的理解<a class="headerlink" href="#id15" title="永久链接至标题"></a></h4> <h4>敏感度的理解<a class="headerlink" href="#id19" title="永久链接至标题"></a></h4>
<p align="center"> <p align="center">
<img src="https://raw.githubusercontent.com/PaddlePaddle/PaddleSlim/develop/docs/docs/images/algo/pruning_3.png" height=200 width=400 hspace='10'/> <br /> <img src="https://raw.githubusercontent.com/PaddlePaddle/PaddleSlim/develop/docs/docs/images/algo/pruning_3.png" height=200 width=400 hspace='10'/> <br />
<strong>图7</strong> <strong>图7</strong>
</p><p><strong>图7</strong>所示,横坐标是将filter剪裁掉的比例,竖坐标是精度的损失,每条彩色虚线表示的是网络中的一个卷积层。 </p><p><strong>图7</strong>所示,横坐标是将filter剪裁掉的比例,竖坐标是精度的损失,每条彩色虚线表示的是网络中的一个卷积层。
以不同的剪裁比例<strong>单独</strong>剪裁一个卷积层,并观察其在验证数据集上的精度损失,并绘出<strong>图7</strong>中的虚线。虚线上升较慢的,对应的卷积层相对不敏感,我们优先剪不敏感的卷积层的filter.</p> 以不同的剪裁比例<strong>单独</strong>剪裁一个卷积层,并观察其在验证数据集上的精度损失,并绘出<strong>图7</strong>中的虚线。虚线上升较慢的,对应的卷积层相对不敏感,我们优先剪不敏感的卷积层的filter.</p>
</div> </div>
<div class="section" id="id16"> <div class="section" id="id20">
<h4>选择最优的剪裁率组合<a class="headerlink" href="#id16" title="永久链接至标题"></a></h4> <h4>选择最优的剪裁率组合<a class="headerlink" href="#id20" title="永久链接至标题"></a></h4>
<p>我们将<strong>图7</strong>中的折线拟合为<strong>图8</strong>中的曲线,每在竖坐标轴上选取一个精度损失值,就在横坐标轴上对应着一组剪裁率,如<strong>图8</strong>中黑色实线所示。 <p>我们将<strong>图7</strong>中的折线拟合为<strong>图8</strong>中的曲线,每在竖坐标轴上选取一个精度损失值,就在横坐标轴上对应着一组剪裁率,如<strong>图8</strong>中黑色实线所示。
用户给定一个模型整体的剪裁率,我们通过移动<strong>图5</strong>中的黑色实线来找到一组满足条件的且合法的剪裁率。</p> 用户给定一个模型整体的剪裁率,我们通过移动<strong>图5</strong>中的黑色实线来找到一组满足条件的且合法的剪裁率。</p>
<p align="center"> <p align="center">
<img src="https://raw.githubusercontent.com/PaddlePaddle/PaddleSlim/develop/docs/docs/images/algo/pruning_4.png" height=200 width=400 hspace='10'/> <br /> <img src="https://raw.githubusercontent.com/PaddlePaddle/PaddleSlim/develop/docs/docs/images/algo/pruning_4.png" height=200 width=400 hspace='10'/> <br />
<strong>图8</strong> <strong>图8</strong>
</p></div> </p></div>
<div class="section" id="id17"> <div class="section" id="id21">
<h4>迭代剪裁<a class="headerlink" href="#id17" title="永久链接至标题"></a></h4> <h4>迭代剪裁<a class="headerlink" href="#id21" title="永久链接至标题"></a></h4>
<p>考虑到多个卷积层间的相关性,一个卷积层的修改可能会影响其它卷积层的敏感度,我们采取了多次剪裁的策略,步骤如下:</p> <p>考虑到多个卷积层间的相关性,一个卷积层的修改可能会影响其它卷积层的敏感度,我们采取了多次剪裁的策略,步骤如下:</p>
<ul class="simple"> <ul class="simple">
<li>step1: 统计各卷积层的敏感度信息</li> <li>step1: 统计各卷积层的敏感度信息</li>
...@@ -350,63 +348,70 @@ $$ ...@@ -350,63 +348,70 @@ $$
</div> </div>
</div> </div>
</div> </div>
<div class="section" id="id18"> <div class="section" id="id22">
<h2>3. 蒸馏<a class="headerlink" href="#id18" title="永久链接至标题"></a></h2> <h2>3. 蒸馏<a class="headerlink" href="#id22" title="永久链接至标题"></a></h2>
<p>一般情况下,模型参数量越多,结构越复杂,其性能越好,但参数也越允余,运算量和资源消耗也越大;模型蒸馏是将复杂网络中的有用信息将复杂网络中的有用信息提取出来提取出来,迁移到一个更小的网络中去,在我们的工具包中,支持两种蒸馏的方法。 <blockquote>
第一种是传统的蒸馏方法(参考论文:<a class="reference external" href="https://arxiv.org/pdf/1503.02531.pdf">Distilling the Knowledge in a Neural Network</a> <div><dl class="docutils">
使用复杂的网络作为teacher模型去监督训练一个参数量和运算量更少的student模型。teacher模型可以是一个或者多个提前训练好的高性能模型。student模型的训练有两个目标:一个是原始的目标函数,为student模型输出的类别概率和label的交叉熵,记为hard-target;另一个是student模型输出的类别概率和teacher模型输出的类别概率的交叉熵,记为soft target,这两个loss加权后得到最终的训练loss,共同监督studuent模型的训练。 <dt>一般情况下,模型参数量越多,结构越复杂,其性能越好,但参数也越允余,运算量和资源消耗也越大;模型蒸馏是将复杂网络中的有用信息将复杂网络中的有用信息提取出来提取出来,迁移到一个更小的网络中去,在我们的工具包中,支持两种蒸馏的方法。</dt>
第二种是基于FSP的蒸馏方法(参考论文:<a class="reference external" href="http://openaccess.thecvf.com/content_cvpr_2017/papers/Yim_A_Gift_From_CVPR_2017_paper.pdf">A Gift from Knowledge Distillation: <dd>第一种是传统的蒸馏方法(参考论文:<a class="reference external" href="https://arxiv.org/pdf/1503.02531.pdf">Distilling the Knowledge in a Neural Network</a></dd>
Fast Optimization, Network Minimization and Transfer Learning</a> </dl>
相比传统的蒸馏方法直接用小模型去拟合大模型的输出,该方法用小模型去拟合大模型不同层特征之间的转换关系,其用一个FSP矩阵(特征的内积)来表示不同层特征之间的关系,大模型和小模型不同层之间分别获得多个FSP矩阵,然后使用L2 loss让小模型的对应层FSP矩阵和大模型对应层的FSP矩阵尽量一致,具体如下图所示。这种方法的优势,通俗的解释是,比如将蒸馏类比成teacher(大模型)教student(小模型)解决一个问题,传统的蒸馏是直接告诉小模型问题的答案,让小模型学习,而学习FSP矩阵是让小模型学习解决问题的中间过程和方法,因此其学到的信息更多。</p> <p>使用复杂的网络作为teacher模型去监督训练一个参数量和运算量更少的student模型。teacher模型可以是一个或者多个提前训练好的高性能模型。student模型的训练有两个目标:一个是原始的目标函数,为student模型输出的类别概率和label的交叉熵,记为hard-target;另一个是student模型输出的类别概率和teacher模型输出的类别概率的交叉熵,记为soft target,这两个loss加权后得到最终的训练loss,共同监督studuent模型的训练。
第二种是基于FSP的蒸馏方法(参考论文:<a href="#id23"><span class="problematic" id="id24">`</span></a>A Gift from Knowledge Distillation:</p>
</div></blockquote>
<dl class="docutils">
<dt>Fast Optimization, Network Minimization and Transfer Learning &lt;<a class="reference external" href="http://openaccess.thecvf.com/content_cvpr_2017/papers/Yim_A_Gift_From_CVPR_2017_paper.pdf">http://openaccess.thecvf.com/content_cvpr_2017/papers/Yim_A_Gift_From_CVPR_2017_paper.pdf</a>&gt;`_)</dt>
<dd>相比传统的蒸馏方法直接用小模型去拟合大模型的输出,该方法用小模型去拟合大模型不同层特征之间的转换关系,其用一个FSP矩阵(特征的内积)来表示不同层特征之间的关系,大模型和小模型不同层之间分别获得多个FSP矩阵,然后使用L2 loss让小模型的对应层FSP矩阵和大模型对应层的FSP矩阵尽量一致,具体如下图所示。这种方法的优势,通俗的解释是,比如将蒸馏类比成teacher(大模型)教student(小模型)解决一个问题,传统的蒸馏是直接告诉小模型问题的答案,让小模型学习,而学习FSP矩阵是让小模型学习解决问题的中间过程和方法,因此其学到的信息更多。</dd>
</dl>
<p align="center"> <p align="center">
<img src="https://raw.githubusercontent.com/PaddlePaddle/PaddleSlim/develop/docs/docs/images/algo/distillation_0.png" height=300 width=600 hspace='10'/> <br /> <img src="https://raw.githubusercontent.com/PaddlePaddle/PaddleSlim/develop/docs/docs/images/algo/distillation_0.png" height=300 width=600 hspace='10'/> <br />
<strong>图9</strong> <strong>图9</strong>
</p><p>由于小模型和大模型之间通过L2 loss进行监督,必须保证两个FSP矩阵的维度必须相同,而FSP矩阵的维度为M*N,其中M、N分别为输入和输出特征的channel数,因此大模型和小模型的FSP矩阵需要一一对应。</p> </p>
</div>
<div class="section" id="id19">
<h2>4. 轻量级模型结构搜索<a class="headerlink" href="#id19" title="永久链接至标题"></a></h2> 由于小模型和大模型之间通过L2 loss进行监督,必须保证两个FSP矩阵的维度必须相同,而FSP矩阵的维度为M*N,其中M、N分别为输入和输出特征的channel数,因此大模型和小模型的FSP矩阵需要一一对应。</div>
<div class="section" id="id25">
<h2>4. 轻量级模型结构搜索<a class="headerlink" href="#id25" title="永久链接至标题"></a></h2>
<p>深度学习模型在很多任务上都取得了不错的效果,网络结构的好坏对最终模型的效果有非常重要的影响。手工设计网络需要非常丰富的经验和众多尝试,并且众多的超参数和网络结构参数会产生爆炸性的组合,常规的random search几乎不可行,因此最近几年自动模型搜索技术(Neural Architecture Search)成为研究热点。区别于传统NAS,我们专注在搜索精度高并且速度快的模型结构,我们将该功能统称为Light-NAS.</p> <p>深度学习模型在很多任务上都取得了不错的效果,网络结构的好坏对最终模型的效果有非常重要的影响。手工设计网络需要非常丰富的经验和众多尝试,并且众多的超参数和网络结构参数会产生爆炸性的组合,常规的random search几乎不可行,因此最近几年自动模型搜索技术(Neural Architecture Search)成为研究热点。区别于传统NAS,我们专注在搜索精度高并且速度快的模型结构,我们将该功能统称为Light-NAS.</p>
<div class="section" id="id20"> <div class="section" id="id26">
<h3>4.1 搜索策略<a class="headerlink" href="#id20" title="永久链接至标题"></a></h3> <h3>4.1 搜索策略<a class="headerlink" href="#id26" title="永久链接至标题"></a></h3>
<p>搜索策略定义了使用怎样的算法可以快速、准确找到最优的网络结构参数配置。常见的搜索方法包括:强化学习、贝叶斯优化、进化算法、基于梯度的算法。我们当前的实现以模拟退火算法为主。</p> <p>搜索策略定义了使用怎样的算法可以快速、准确找到最优的网络结构参数配置。常见的搜索方法包括:强化学习、贝叶斯优化、进化算法、基于梯度的算法。我们当前的实现以模拟退火算法为主。</p>
<div class="section" id="id21"> <div class="section" id="id27">
<h4>4.1.1 模拟退火<a class="headerlink" href="#id21" title="永久链接至标题"></a></h4> <h4>4.1.1 模拟退火<a class="headerlink" href="#id27" title="永久链接至标题"></a></h4>
<p>模拟退火算法来源于固体退火原理,将固体加温至充分高,再让其徐徐冷却,加温时,固体内部粒子随温升变为无序状,内能增大,而徐徐冷却时粒子渐趋有序,在每个温度都达到平衡态,最后在常温时达到基态,内能减为最小。</p> <p>模拟退火算法来源于固体退火原理,将固体加温至充分高,再让其徐徐冷却,加温时,固体内部粒子随温升变为无序状,内能增大,而徐徐冷却时粒子渐趋有序,在每个温度都达到平衡态,最后在常温时达到基态,内能减为最小。</p>
<p>鉴于物理中固体物质的退火过程与一般组合优化问题之间的相似性,我们将其用于网络结构的搜索。</p> <p>鉴于物理中固体物质的退火过程与一般组合优化问题之间的相似性,我们将其用于网络结构的搜索。</p>
<p>使用模拟退火算法搜索模型的过程如下:</p> <p>使用模拟退火算法搜索模型的过程如下:</p>
<p>$$ <p>$$
T_k = T_0*\theta^k T_k = T_0*theta^k
$$</p> $$</p>
<p>\begin{equation} <p>begin{equation}
P(r_k) = P(r_k) =
\begin{cases} begin{cases}
e^{\frac{(r_k-r)}{T_k}} &amp; r_k &lt; r\ e^{frac{(r_k-r)}{T_k}} &amp; r_k &lt; r1 &amp; r_k&gt;=r
1 &amp; r_k&gt;=r end{cases}
\end{cases} end{equation}</p>
\end{equation}</p> <p>在第k次迭代,搜到的网络为$N_k$, 对$N_k$训练若干epoch后,在测试集上得到reward为$r_k$, 以概率$P(r_k)$接受$r_k$,即执行$r=r_k$。$r$在搜索过程起始时被初始化为0. $T_0$为初始化温度,$theta$为温度衰减系数,$T_k$为第k次迭代的温度。</p>
<p>在第k次迭代,搜到的网络为$N_k$, 对$N_k$训练若干epoch后,在测试集上得到reward为$r_k$, 以概率$P(r_k)$接受$r_k$,即执行$r=r_k$。$r$在搜索过程起始时被初始化为0. $T_0$为初始化温度,$\theta$为温度衰减系数,$T_k$为第k次迭代的温度。</p>
<p>在我们的NAS任务中,区别于RL每次重新生成一个完整的网络,我们将网络结构映射成一段编码,第一次随机初始化,然后每次随机修改编码中的一部分(对应于网络结构的一部分)生成一个新的编码,然后将这个编码再映射回网络结构,通过在训练集上训练一定的epochs后的精度以及网络延时融合获得reward,来指导退火算法的收敛。</p> <p>在我们的NAS任务中,区别于RL每次重新生成一个完整的网络,我们将网络结构映射成一段编码,第一次随机初始化,然后每次随机修改编码中的一部分(对应于网络结构的一部分)生成一个新的编码,然后将这个编码再映射回网络结构,通过在训练集上训练一定的epochs后的精度以及网络延时融合获得reward,来指导退火算法的收敛。</p>
</div> </div>
</div> </div>
<div class="section" id="id22"> <div class="section" id="id28">
<h3>4.2 搜索空间<a class="headerlink" href="#id22" title="永久链接至标题"></a></h3> <h3>4.2 搜索空间<a class="headerlink" href="#id28" title="永久链接至标题"></a></h3>
<p>搜索空间定义了优化问题的变量,变量规模决定了搜索算法的难度和搜索时间。因此为了加快搜索速度,定义一个合理的搜索空间至关重要。在Light-NAS中,为了加速搜索速度,我们将一个网络划分为多个block,先手动按链状层级结构堆叠c,再 使用搜索算法自动搜索每个block内部的结构。</p> <p>搜索空间定义了优化问题的变量,变量规模决定了搜索算法的难度和搜索时间。因此为了加快搜索速度,定义一个合理的搜索空间至关重要。在Light-NAS中,为了加速搜索速度,我们将一个网络划分为多个block,先手动按链状层级结构堆叠c,再 使用搜索算法自动搜索每个block内部的结构。</p>
<p>因为要搜索出在移动端运行速度快的模型,我们参考了MobileNetV2中的Linear Bottlenecks和Inverted residuals结构,搜索每一个Inverted residuals中的具体参数,包括kernelsize、channel扩张倍数、重复次数、channels number。如图10所示:</p> <p>因为要搜索出在移动端运行速度快的模型,我们参考了MobileNetV2中的Linear Bottlenecks和Inverted residuals结构,搜索每一个Inverted residuals中的具体参数,包括kernelsize、channel扩张倍数、重复次数、channels number。如图10所示:</p>
<p align="center"> <p align="center">
<img src="https://raw.githubusercontent.com/PaddlePaddle/PaddleSlim/develop/docs/docs/images/algo/light-nas-block.png" height=300 width=600 hspace='10'/> <br /> <img src="https://raw.githubusercontent.com/PaddlePaddle/PaddleSlim/develop/docs/docs/images/algo/light-nas-block.png" height=300 width=600 hspace='10'/> <br />
<strong>图10</strong> <strong>图10</strong>
</p></div> </p></div>
<div class="section" id="id23"> <div class="section" id="id29">
<h3>4.3 模型延时评估<a class="headerlink" href="#id23" title="永久链接至标题"></a></h3> <h3>4.3 模型延时评估<a class="headerlink" href="#id29" title="永久链接至标题"></a></h3>
<p>搜索过程支持 FLOPS 约束和模型延时约束。而基于 Android/iOS 移动端、开发板等硬件平台,迭代搜索过程中不断测试模型的延时不仅消耗时间而且非常不方便,因此我们开发了模型延时评估器来评估搜索得到模型的延时。通过延时评估器评估得到的延时与模型实际测试的延时波动偏差小于 10%。</p> <p>搜索过程支持 FLOPS 约束和模型延时约束。而基于 Android/iOS 移动端、开发板等硬件平台,迭代搜索过程中不断测试模型的延时不仅消耗时间而且非常不方便,因此我们开发了模型延时评估器来评估搜索得到模型的延时。通过延时评估器评估得到的延时与模型实际测试的延时波动偏差小于 10%。</p>
<p>延时评估器分为配置硬件延时评估器和评估模型延时两个阶段,配置硬件延时评估器只需要执行一次,而评估模型延时则在搜索过程中不断评估搜索得到的模型延时。</p> <p>延时评估器分为配置硬件延时评估器和评估模型延时两个阶段,配置硬件延时评估器只需要执行一次,而评估模型延时则在搜索过程中不断评估搜索得到的模型延时。</p>
<ul class="simple"> <ul class="simple">
<li>配置硬件延时评估器<ol> <li>配置硬件延时评估器<ol class="arabic">
<li>获取搜索空间中所有不重复的 op 及其参数</li> <li>获取搜索空间中所有不重复的 op 及其参数</li>
<li>获取每组 op 及其参数的延时</li> <li>获取每组 op 及其参数的延时</li>
</ol> </ol>
</li> </li>
<li>评估模型延时<ol> <li>评估模型延时<ol class="arabic">
<li>获取给定模型的所有 op 及其参数</li> <li>获取给定模型的所有 op 及其参数</li>
<li>根据给定模型的所有 op 及参数,利用延时评估器去估计模型的延时</li> <li>根据给定模型的所有 op 及参数,利用延时评估器去估计模型的延时</li>
</ol> </ol>
...@@ -414,9 +419,9 @@ e^{\frac{(r_k-r)}{T_k}} &amp; r_k &lt; r\ ...@@ -414,9 +419,9 @@ e^{\frac{(r_k-r)}{T_k}} &amp; r_k &lt; r\
</ul> </ul>
</div> </div>
</div> </div>
<div class="section" id="id24"> <div class="section" id="id30">
<h2>5. 参考文献<a class="headerlink" href="#id24" title="永久链接至标题"></a></h2> <h2>5. 参考文献<a class="headerlink" href="#id30" title="永久链接至标题"></a></h2>
<ol class="simple"> <ol class="arabic simple">
<li><a class="reference external" href="https://media.nips.cc/Conferences/2015/tutorialslides/Dally-NIPS-Tutorial-2015.pdf">High-Performance Hardware for Machine Learning</a></li> <li><a class="reference external" href="https://media.nips.cc/Conferences/2015/tutorialslides/Dally-NIPS-Tutorial-2015.pdf">High-Performance Hardware for Machine Learning</a></li>
<li><a class="reference external" href="https://arxiv.org/pdf/1806.08342.pdf">Quantizing deep convolutional networks for efficient inference: A whitepaper</a></li> <li><a class="reference external" href="https://arxiv.org/pdf/1806.08342.pdf">Quantizing deep convolutional networks for efficient inference: A whitepaper</a></li>
<li><a class="reference external" href="https://arxiv.org/pdf/1608.08710.pdf">Pruning Filters for Efficient ConvNets</a></li> <li><a class="reference external" href="https://arxiv.org/pdf/1608.08710.pdf">Pruning Filters for Efficient ConvNets</a></li>
......
...@@ -83,7 +83,7 @@ ...@@ -83,7 +83,7 @@
<ul class="current"> <ul class="current">
<li class="toctree-l1"><a class="reference internal" href="../index_en.html">English Documents</a></li> <li class="toctree-l1"><a class="reference internal" href="../index_en.html">English Documents</a></li>
<li class="toctree-l1"><a class="reference internal" href="../intro.html">PaddleSlim简介</a></li> <li class="toctree-l1"><a class="reference internal" href="../intro.html">介绍</a></li>
<li class="toctree-l1"><a class="reference internal" href="../install.html">安装</a></li> <li class="toctree-l1"><a class="reference internal" href="../install.html">安装</a></li>
<li class="toctree-l1"><a class="reference internal" href="../quick_start/index.html">快速开始</a></li> <li class="toctree-l1"><a class="reference internal" href="../quick_start/index.html">快速开始</a></li>
<li class="toctree-l1"><a class="reference internal" href="../tutorials/index.html">进阶教程</a></li> <li class="toctree-l1"><a class="reference internal" href="../tutorials/index.html">进阶教程</a></li>
...@@ -96,7 +96,7 @@ ...@@ -96,7 +96,7 @@
</li> </li>
<li class="toctree-l2"><a class="reference internal" href="nas_api.html">SA-NAS</a></li> <li class="toctree-l2"><a class="reference internal" href="nas_api.html">SA-NAS</a></li>
<li class="toctree-l2"><a class="reference internal" href="one_shot_api.html">OneShotNAS</a></li> <li class="toctree-l2"><a class="reference internal" href="one_shot_api.html">OneShotNAS</a></li>
<li class="toctree-l2"><a class="reference internal" href="pantheon_api.html">多进程蒸馏</a></li> <li class="toctree-l2"><a class="reference internal" href="pantheon_api.html">大规模可扩展知识蒸馏框架 Pantheon</a></li>
<li class="toctree-l2"><a class="reference internal" href="prune_api.html">卷积层通道剪裁</a></li> <li class="toctree-l2"><a class="reference internal" href="prune_api.html">卷积层通道剪裁</a></li>
<li class="toctree-l2"><a class="reference internal" href="quantization_api.html">量化</a></li> <li class="toctree-l2"><a class="reference internal" href="quantization_api.html">量化</a></li>
<li class="toctree-l2"><a class="reference internal" href="single_distiller_api.html">简单蒸馏</a></li> <li class="toctree-l2"><a class="reference internal" href="single_distiller_api.html">简单蒸馏</a></li>
......
...@@ -35,7 +35,7 @@ ...@@ -35,7 +35,7 @@
<link rel="search" title="搜索" href="../search.html"/> <link rel="search" title="搜索" href="../search.html"/>
<link rel="top" title="PaddleSlim 1.0 文档" href="../index.html"/> <link rel="top" title="PaddleSlim 1.0 文档" href="../index.html"/>
<link rel="next" title="模型分析" href="analysis_api.html"/> <link rel="next" title="模型分析" href="analysis_api.html"/>
<link rel="prev" title="图像分类模型通道剪裁-敏感度分析" href="../tutorials/image_classification_sensitivity_analysis_tutorial.html"/> <link rel="prev" title="目标检测模型敏感度分析教程" href="../tutorials/paddledetection_slim_sensitivy_tutorial.html"/>
<script src="../_static/js/modernizr.min.js"></script> <script src="../_static/js/modernizr.min.js"></script>
...@@ -82,7 +82,7 @@ ...@@ -82,7 +82,7 @@
<ul class="current"> <ul class="current">
<li class="toctree-l1"><a class="reference internal" href="../index_en.html">English Documents</a></li> <li class="toctree-l1"><a class="reference internal" href="../index_en.html">English Documents</a></li>
<li class="toctree-l1"><a class="reference internal" href="../intro.html">PaddleSlim简介</a></li> <li class="toctree-l1"><a class="reference internal" href="../intro.html">介绍</a></li>
<li class="toctree-l1"><a class="reference internal" href="../install.html">安装</a></li> <li class="toctree-l1"><a class="reference internal" href="../install.html">安装</a></li>
<li class="toctree-l1"><a class="reference internal" href="../quick_start/index.html">快速开始</a></li> <li class="toctree-l1"><a class="reference internal" href="../quick_start/index.html">快速开始</a></li>
<li class="toctree-l1"><a class="reference internal" href="../tutorials/index.html">进阶教程</a></li> <li class="toctree-l1"><a class="reference internal" href="../tutorials/index.html">进阶教程</a></li>
...@@ -90,7 +90,7 @@ ...@@ -90,7 +90,7 @@
<li class="toctree-l2"><a class="reference internal" href="analysis_api.html">模型分析</a></li> <li class="toctree-l2"><a class="reference internal" href="analysis_api.html">模型分析</a></li>
<li class="toctree-l2"><a class="reference internal" href="nas_api.html">SA-NAS</a></li> <li class="toctree-l2"><a class="reference internal" href="nas_api.html">SA-NAS</a></li>
<li class="toctree-l2"><a class="reference internal" href="one_shot_api.html">OneShotNAS</a></li> <li class="toctree-l2"><a class="reference internal" href="one_shot_api.html">OneShotNAS</a></li>
<li class="toctree-l2"><a class="reference internal" href="pantheon_api.html">多进程蒸馏</a></li> <li class="toctree-l2"><a class="reference internal" href="pantheon_api.html">大规模可扩展知识蒸馏框架 Pantheon</a></li>
<li class="toctree-l2"><a class="reference internal" href="prune_api.html">卷积层通道剪裁</a></li> <li class="toctree-l2"><a class="reference internal" href="prune_api.html">卷积层通道剪裁</a></li>
<li class="toctree-l2"><a class="reference internal" href="quantization_api.html">量化</a></li> <li class="toctree-l2"><a class="reference internal" href="quantization_api.html">量化</a></li>
<li class="toctree-l2"><a class="reference internal" href="single_distiller_api.html">简单蒸馏</a></li> <li class="toctree-l2"><a class="reference internal" href="single_distiller_api.html">简单蒸馏</a></li>
...@@ -151,7 +151,7 @@ ...@@ -151,7 +151,7 @@
<li class="toctree-l1"><a class="reference internal" href="analysis_api.html">模型分析</a></li> <li class="toctree-l1"><a class="reference internal" href="analysis_api.html">模型分析</a></li>
<li class="toctree-l1"><a class="reference internal" href="nas_api.html">SA-NAS</a></li> <li class="toctree-l1"><a class="reference internal" href="nas_api.html">SA-NAS</a></li>
<li class="toctree-l1"><a class="reference internal" href="one_shot_api.html">OneShotNAS</a></li> <li class="toctree-l1"><a class="reference internal" href="one_shot_api.html">OneShotNAS</a></li>
<li class="toctree-l1"><a class="reference internal" href="pantheon_api.html">多进程蒸馏</a></li> <li class="toctree-l1"><a class="reference internal" href="pantheon_api.html">大规模可扩展知识蒸馏框架 Pantheon</a></li>
<li class="toctree-l1"><a class="reference internal" href="prune_api.html">卷积层通道剪裁</a></li> <li class="toctree-l1"><a class="reference internal" href="prune_api.html">卷积层通道剪裁</a></li>
<li class="toctree-l1"><a class="reference internal" href="quantization_api.html">量化</a></li> <li class="toctree-l1"><a class="reference internal" href="quantization_api.html">量化</a></li>
<li class="toctree-l1"><a class="reference internal" href="single_distiller_api.html">简单蒸馏</a></li> <li class="toctree-l1"><a class="reference internal" href="single_distiller_api.html">简单蒸馏</a></li>
...@@ -171,7 +171,7 @@ ...@@ -171,7 +171,7 @@
<a href="analysis_api.html" class="btn btn-neutral float-right" title="模型分析" accesskey="n">Next <span class="fa fa-arrow-circle-right"></span></a> <a href="analysis_api.html" class="btn btn-neutral float-right" title="模型分析" accesskey="n">Next <span class="fa fa-arrow-circle-right"></span></a>
<a href="../tutorials/image_classification_sensitivity_analysis_tutorial.html" class="btn btn-neutral" title="图像分类模型通道剪裁-敏感度分析" accesskey="p"><span class="fa fa-arrow-circle-left"></span> Previous</a> <a href="../tutorials/paddledetection_slim_sensitivy_tutorial.html" class="btn btn-neutral" title="目标检测模型敏感度分析教程" accesskey="p"><span class="fa fa-arrow-circle-left"></span> Previous</a>
</div> </div>
......
...@@ -83,7 +83,7 @@ ...@@ -83,7 +83,7 @@
<ul class="current"> <ul class="current">
<li class="toctree-l1"><a class="reference internal" href="../index_en.html">English Documents</a></li> <li class="toctree-l1"><a class="reference internal" href="../index_en.html">English Documents</a></li>
<li class="toctree-l1"><a class="reference internal" href="../intro.html">PaddleSlim简介</a></li> <li class="toctree-l1"><a class="reference internal" href="../intro.html">介绍</a></li>
<li class="toctree-l1"><a class="reference internal" href="../install.html">安装</a></li> <li class="toctree-l1"><a class="reference internal" href="../install.html">安装</a></li>
<li class="toctree-l1"><a class="reference internal" href="../quick_start/index.html">快速开始</a></li> <li class="toctree-l1"><a class="reference internal" href="../quick_start/index.html">快速开始</a></li>
<li class="toctree-l1"><a class="reference internal" href="../tutorials/index.html">进阶教程</a></li> <li class="toctree-l1"><a class="reference internal" href="../tutorials/index.html">进阶教程</a></li>
...@@ -95,7 +95,7 @@ ...@@ -95,7 +95,7 @@
</ul> </ul>
</li> </li>
<li class="toctree-l2"><a class="reference internal" href="one_shot_api.html">OneShotNAS</a></li> <li class="toctree-l2"><a class="reference internal" href="one_shot_api.html">OneShotNAS</a></li>
<li class="toctree-l2"><a class="reference internal" href="pantheon_api.html">多进程蒸馏</a></li> <li class="toctree-l2"><a class="reference internal" href="pantheon_api.html">大规模可扩展知识蒸馏框架 Pantheon</a></li>
<li class="toctree-l2"><a class="reference internal" href="prune_api.html">卷积层通道剪裁</a></li> <li class="toctree-l2"><a class="reference internal" href="prune_api.html">卷积层通道剪裁</a></li>
<li class="toctree-l2"><a class="reference internal" href="quantization_api.html">量化</a></li> <li class="toctree-l2"><a class="reference internal" href="quantization_api.html">量化</a></li>
<li class="toctree-l2"><a class="reference internal" href="single_distiller_api.html">简单蒸馏</a></li> <li class="toctree-l2"><a class="reference internal" href="single_distiller_api.html">简单蒸馏</a></li>
...@@ -263,7 +263,7 @@ ...@@ -263,7 +263,7 @@
<li><strong>tokens(list):</strong> - 一组tokens。tokens的长度和范围取决于搜索空间。</li> <li><strong>tokens(list):</strong> - 一组tokens。tokens的长度和范围取决于搜索空间。</li>
</ul> </ul>
<p><strong>返回:</strong> <p><strong>返回:</strong>
根据传入的token得到一个模型结构实例。</p> 根据传入的token得到一个模型结构实例列表</p>
<p><strong>示例代码:</strong></p> <p><strong>示例代码:</strong></p>
<div class="highlight-python"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">paddle.fluid</span> <span class="k">as</span> <span class="nn">fluid</span> <div class="highlight-python"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">paddle.fluid</span> <span class="k">as</span> <span class="nn">fluid</span>
<span class="kn">from</span> <span class="nn">paddleslim.nas</span> <span class="kn">import</span> <span class="n">SANAS</span> <span class="kn">from</span> <span class="nn">paddleslim.nas</span> <span class="kn">import</span> <span class="n">SANAS</span>
...@@ -284,6 +284,13 @@ ...@@ -284,6 +284,13 @@
<p><strong>返回:</strong> <p><strong>返回:</strong>
搜索过程中最好的token,reward和当前训练的token,形式为dict。</p> 搜索过程中最好的token,reward和当前训练的token,形式为dict。</p>
<p><strong>示例代码:</strong></p> <p><strong>示例代码:</strong></p>
<div class="highlight-python"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">paddle.fluid</span> <span class="k">as</span> <span class="nn">fluid</span>
<span class="kn">from</span> <span class="nn">paddleslim.nas</span> <span class="kn">import</span> <span class="n">SANAS</span>
<span class="n">config</span> <span class="o">=</span> <span class="p">[(</span><span class="s1">&#39;MobileNetV2Space&#39;</span><span class="p">)]</span>
<span class="n">sanas</span> <span class="o">=</span> <span class="n">SANAS</span><span class="p">(</span><span class="n">configs</span><span class="o">=</span><span class="n">config</span><span class="p">)</span>
<span class="nb">print</span><span class="p">(</span><span class="n">sanas</span><span class="o">.</span><span class="n">current_info</span><span class="p">())</span>
</pre></div>
</div>
</div></blockquote> </div></blockquote>
</div> </div>
</div> </div>
......
...@@ -35,7 +35,7 @@ ...@@ -35,7 +35,7 @@
<link rel="search" title="搜索" href="../search.html"/> <link rel="search" title="搜索" href="../search.html"/>
<link rel="top" title="PaddleSlim 1.0 文档" href="../index.html"/> <link rel="top" title="PaddleSlim 1.0 文档" href="../index.html"/>
<link rel="up" title="API文档" href="index.html"/> <link rel="up" title="API文档" href="index.html"/>
<link rel="next" title="多进程蒸馏" href="pantheon_api.html"/> <link rel="next" title="大规模可扩展知识蒸馏框架 Pantheon" href="pantheon_api.html"/>
<link rel="prev" title="SA-NAS" href="nas_api.html"/> <link rel="prev" title="SA-NAS" href="nas_api.html"/>
...@@ -83,7 +83,7 @@ ...@@ -83,7 +83,7 @@
<ul class="current"> <ul class="current">
<li class="toctree-l1"><a class="reference internal" href="../index_en.html">English Documents</a></li> <li class="toctree-l1"><a class="reference internal" href="../index_en.html">English Documents</a></li>
<li class="toctree-l1"><a class="reference internal" href="../intro.html">PaddleSlim简介</a></li> <li class="toctree-l1"><a class="reference internal" href="../intro.html">介绍</a></li>
<li class="toctree-l1"><a class="reference internal" href="../install.html">安装</a></li> <li class="toctree-l1"><a class="reference internal" href="../install.html">安装</a></li>
<li class="toctree-l1"><a class="reference internal" href="../quick_start/index.html">快速开始</a></li> <li class="toctree-l1"><a class="reference internal" href="../quick_start/index.html">快速开始</a></li>
<li class="toctree-l1"><a class="reference internal" href="../tutorials/index.html">进阶教程</a></li> <li class="toctree-l1"><a class="reference internal" href="../tutorials/index.html">进阶教程</a></li>
...@@ -96,7 +96,7 @@ ...@@ -96,7 +96,7 @@
<li class="toctree-l3"><a class="reference internal" href="#supermnasnet">SuperMnasnet</a></li> <li class="toctree-l3"><a class="reference internal" href="#supermnasnet">SuperMnasnet</a></li>
</ul> </ul>
</li> </li>
<li class="toctree-l2"><a class="reference internal" href="pantheon_api.html">多进程蒸馏</a></li> <li class="toctree-l2"><a class="reference internal" href="pantheon_api.html">大规模可扩展知识蒸馏框架 Pantheon</a></li>
<li class="toctree-l2"><a class="reference internal" href="prune_api.html">卷积层通道剪裁</a></li> <li class="toctree-l2"><a class="reference internal" href="prune_api.html">卷积层通道剪裁</a></li>
<li class="toctree-l2"><a class="reference internal" href="quantization_api.html">量化</a></li> <li class="toctree-l2"><a class="reference internal" href="quantization_api.html">量化</a></li>
<li class="toctree-l2"><a class="reference internal" href="single_distiller_api.html">简单蒸馏</a></li> <li class="toctree-l2"><a class="reference internal" href="single_distiller_api.html">简单蒸馏</a></li>
...@@ -331,7 +331,7 @@ return x, acc</div></blockquote> ...@@ -331,7 +331,7 @@ return x, acc</div></blockquote>
<div class="rst-footer-buttons" role="navigation" aria-label="footer navigation"> <div class="rst-footer-buttons" role="navigation" aria-label="footer navigation">
<a href="pantheon_api.html" class="btn btn-neutral float-right" title="多进程蒸馏" accesskey="n">Next <span class="fa fa-arrow-circle-right"></span></a> <a href="pantheon_api.html" class="btn btn-neutral float-right" title="大规模可扩展知识蒸馏框架 Pantheon" accesskey="n">Next <span class="fa fa-arrow-circle-right"></span></a>
<a href="nas_api.html" class="btn btn-neutral" title="SA-NAS" accesskey="p"><span class="fa fa-arrow-circle-left"></span> Previous</a> <a href="nas_api.html" class="btn btn-neutral" title="SA-NAS" accesskey="p"><span class="fa fa-arrow-circle-left"></span> Previous</a>
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>多进程蒸馏 &mdash; PaddleSlim 1.0 文档</title> <title>大规模可扩展知识蒸馏框架 Pantheon &mdash; PaddleSlim 1.0 文档</title>
...@@ -83,7 +83,7 @@ ...@@ -83,7 +83,7 @@
<ul class="current"> <ul class="current">
<li class="toctree-l1"><a class="reference internal" href="../index_en.html">English Documents</a></li> <li class="toctree-l1"><a class="reference internal" href="../index_en.html">English Documents</a></li>
<li class="toctree-l1"><a class="reference internal" href="../intro.html">PaddleSlim简介</a></li> <li class="toctree-l1"><a class="reference internal" href="../intro.html">介绍</a></li>
<li class="toctree-l1"><a class="reference internal" href="../install.html">安装</a></li> <li class="toctree-l1"><a class="reference internal" href="../install.html">安装</a></li>
<li class="toctree-l1"><a class="reference internal" href="../quick_start/index.html">快速开始</a></li> <li class="toctree-l1"><a class="reference internal" href="../quick_start/index.html">快速开始</a></li>
<li class="toctree-l1"><a class="reference internal" href="../tutorials/index.html">进阶教程</a></li> <li class="toctree-l1"><a class="reference internal" href="../tutorials/index.html">进阶教程</a></li>
...@@ -91,7 +91,7 @@ ...@@ -91,7 +91,7 @@
<li class="toctree-l2"><a class="reference internal" href="analysis_api.html">模型分析</a></li> <li class="toctree-l2"><a class="reference internal" href="analysis_api.html">模型分析</a></li>
<li class="toctree-l2"><a class="reference internal" href="nas_api.html">SA-NAS</a></li> <li class="toctree-l2"><a class="reference internal" href="nas_api.html">SA-NAS</a></li>
<li class="toctree-l2"><a class="reference internal" href="one_shot_api.html">OneShotNAS</a></li> <li class="toctree-l2"><a class="reference internal" href="one_shot_api.html">OneShotNAS</a></li>
<li class="toctree-l2 current"><a class="current reference internal" href="#">多进程蒸馏</a><ul> <li class="toctree-l2 current"><a class="current reference internal" href="#">大规模可扩展知识蒸馏框架 Pantheon</a><ul>
<li class="toctree-l3"><a class="reference internal" href="#teacher">Teacher</a></li> <li class="toctree-l3"><a class="reference internal" href="#teacher">Teacher</a></li>
<li class="toctree-l3"><a class="reference internal" href="#student">Student</a></li> <li class="toctree-l3"><a class="reference internal" href="#student">Student</a></li>
</ul> </ul>
...@@ -137,7 +137,7 @@ ...@@ -137,7 +137,7 @@
<li><a href="index.html">API文档</a> &raquo;</li> <li><a href="index.html">API文档</a> &raquo;</li>
<li>多进程蒸馏</li> <li>大规模可扩展知识蒸馏框架 Pantheon</li>
<li class="wy-breadcrumbs-aside"> <li class="wy-breadcrumbs-aside">
...@@ -151,8 +151,8 @@ ...@@ -151,8 +151,8 @@
<div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article"> <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
<div itemprop="articleBody"> <div itemprop="articleBody">
<div class="section" id="id1"> <div class="section" id="pantheon">
<h1>多进程蒸馏<a class="headerlink" href="#id1" title="永久链接至标题"></a></h1> <h1>大规模可扩展知识蒸馏框架 Pantheon<a class="headerlink" href="#pantheon" title="永久链接至标题"></a></h1>
<div class="section" id="teacher"> <div class="section" id="teacher">
<h2>Teacher<a class="headerlink" href="#teacher" title="永久链接至标题"></a></h2> <h2>Teacher<a class="headerlink" href="#teacher" title="永久链接至标题"></a></h2>
<p>pantheon.Teacher() <a class="reference external" href="https://github.com/PaddlePaddle/PaddleSlim/blob/develop/paddleslim/pantheon/teacher.py#L78">source</a></p> <p>pantheon.Teacher() <a class="reference external" href="https://github.com/PaddlePaddle/PaddleSlim/blob/develop/paddleslim/pantheon/teacher.py#L78">source</a></p>
...@@ -164,8 +164,10 @@ ...@@ -164,8 +164,10 @@
</ul> </ul>
<p><strong>Return:</strong> An object of class Teacher</p> <p><strong>Return:</strong> An object of class Teacher</p>
<p>pantheon.Teacher.start() <a class="reference external" href="https://github.com/PaddlePaddle/PaddleSlim/blob/develop/paddleslim/pantheon/teacher.py#L133">source</a></p> <p>pantheon.Teacher.start() <a class="reference external" href="https://github.com/PaddlePaddle/PaddleSlim/blob/develop/paddleslim/pantheon/teacher.py#L133">source</a></p>
<p>: Start teacher service, sychronize with student and launch the thread <dl class="docutils">
to monitor commands from student.</p> <dt>: Start teacher service, sychronize with student and launch the thread</dt>
<dd>to monitor commands from student.</dd>
</dl>
<p><strong>Args:</strong> None</p> <p><strong>Args:</strong> None</p>
<p><strong>Return:</strong> None</p> <p><strong>Return:</strong> None</p>
<p>pantheon.Teacher.send(data) <a class="reference external" href="https://github.com/PaddlePaddle/PaddleSlim/blob/develop/paddleslim/pantheon/teacher.py#L181">source</a></p> <p>pantheon.Teacher.send(data) <a class="reference external" href="https://github.com/PaddlePaddle/PaddleSlim/blob/develop/paddleslim/pantheon/teacher.py#L181">source</a></p>
...@@ -190,49 +192,68 @@ to monitor commands from student.</p> ...@@ -190,49 +192,68 @@ to monitor commands from student.</p>
</ul> </ul>
<p><strong>Return:</strong> None</p> <p><strong>Return:</strong> None</p>
<p>pantheon.Teacher.start_knowledge_service(feed_list, schema, program, reader_config, exe, buf_size=10, times=1) <a class="reference external" href="https://github.com/PaddlePaddle/PaddleSlim/blob/develop/paddleslim/pantheon/teacher.py#L259">source</a></p> <p>pantheon.Teacher.start_knowledge_service(feed_list, schema, program, reader_config, exe, buf_size=10, times=1) <a class="reference external" href="https://github.com/PaddlePaddle/PaddleSlim/blob/develop/paddleslim/pantheon/teacher.py#L259">source</a></p>
<p>: Start the knowledge service to generate and transfer knowledge data. In GPU mode, the devices to execute knowledge prediction will be determined by the <dl class="docutils">
environment variable <strong>FLAGS_selected_gpus</strong>, or by <strong>CUDA_VISIBLE_DEVICES</strong> if it is not set, and by <strong>CPU_NUM</strong> (default 1) in CPU mode. Only supported in static graph.</p> <dt>: Start the knowledge service to generate and transfer knowledge data. In GPU mode, the devices to execute knowledge prediction will be determined by the</dt>
<p><strong>Args:</strong></p> <dd><blockquote class="first">
<div>environment variable <strong>FLAGS_selected_gpus</strong>, or by <strong>CUDA_VISIBLE_DEVICES</strong> if it is not set, and by <strong>CPU_NUM</strong> (default 1) in CPU mode. Only supported in static graph.</div></blockquote>
<p class="last"><strong>Args:</strong></p>
</dd>
</dl>
<ul> <ul>
<li><p class="first"><strong>feed_list (list):</strong> - A list of feed Variables or their names for the <li><p class="first"><strong>feed_list (list):</strong> - A list of feed Variables or their names for the
input teacher Program.</p> .. code-block:: guess</p>
<blockquote>
<div><p>input teacher Program.</p>
</div></blockquote>
</li> </li>
<li><p class="first"><strong>schema (dict):</strong> - A dict to specify keys and fetched Variablesto generate knowledge.</p> <li><p class="first"><strong>schema (dict):</strong> - A dict to specify keys and fetched Variables
.. code-block:: guess</p>
<blockquote>
<div><p>to generate knowledge.</p>
</div></blockquote>
</li> </li>
<li><p class="first"><strong>program (fluid.Program):</strong> - Inference Program of the teacher model.</p> <li><p class="first"><strong>program (fluid.Program):</strong> - Inference Program of the teacher model.</p>
</li> </li>
<li><p class="first"><strong>reader_config (dict):</strong> - The config for data reader. Support all the three types of generators used by <a class="reference external" href="https://www.paddlepaddle.org.cn/documentation/docs/en/api/io/PyReader.html">fluid.io.PyReader</a> and <a class="reference external" href="https://www.paddlepaddle.org.cn/documentation/docs/en/api/io/DataLoader.html#dataloader">fluid.io.DataLoader</a>, and their configs contain the key-value pair of the generator type and a generator object, plus other necessary argument pairs. See the following:</p> <li><p class="first"><strong>reader_config (dict):</strong> - The config for data reader. Support all the three types of generators used by <a class="reference external" href="https://www.paddlepaddle.org.cn/documentation/docs/en/api/io/PyReader.html">fluid.io.PyReader</a> and <a class="reference external" href="https://www.paddlepaddle.org.cn/documentation/docs/en/api/io/DataLoader.html#dataloader">fluid.io.DataLoader</a>, and their configs contain the key-value pair of the generator type and a generator object, plus other necessary argument pairs. See the following:</p>
<ol class="simple"> <blockquote>
<div><ol class="arabic simple">
<li><strong>sample generator:</strong></li> <li><strong>sample generator:</strong></li>
</ol> </ol>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">reader_config</span><span class="o">=</span><span class="p">{</span><span class="s2">&quot;sample_generator&quot;</span><span class="p">:</span> <span class="n">some_sample_generator</span><span class="p">,</span> </div></blockquote>
<span class="s2">&quot;batch_size&quot;</span><span class="p">:</span> <span class="n">batch_size</span><span class="p">,</span> <span class="s2">&quot;drop_last&quot;</span><span class="p">:</span> <span class="n">drop_last</span><span class="p">}</span> <div class="highlight-guess"><div class="highlight"><pre><span></span> <span class="n">reader_config</span><span class="o">=</span><span class="err">{</span><span class="ss">&quot;sample_generator&quot;</span><span class="p">:</span> <span class="n">some_sample_generator</span><span class="p">,</span>
<span class="c1"># drop_last set to True by default</span> <span class="ss">&quot;batch_size&quot;</span><span class="p">:</span> <span class="n">batch_size</span><span class="p">,</span> <span class="ss">&quot;drop_last&quot;</span><span class="p">:</span> <span class="n">drop_last</span><span class="err">}</span>
<span class="o">#</span> <span class="n">drop_last</span> <span class="k">set</span> <span class="k">to</span> <span class="k">True</span> <span class="k">by</span> <span class="k">default</span>
<span class="mi">2</span><span class="p">)</span> <span class="o">**</span><span class="n">sample</span> <span class="n">list</span> <span class="n">generator</span><span class="p">:</span><span class="o">**</span>
</pre></div> </pre></div>
</div> </div>
<ol class="simple"> <div class="highlight-guess"><div class="highlight"><pre><span></span> <span class="n">reader_config</span><span class="o">=</span><span class="err">{</span><span class="ss">&quot;sample_list_generator&quot;</span><span class="p">:</span> <span class="n">some_sample_list_generator</span><span class="err">}</span>
<li><strong>sample list generator:</strong></li>
</ol> <span class="mi">3</span><span class="p">)</span> <span class="o">**</span><span class="n">batch</span> <span class="n">generator</span><span class="p">:</span><span class="o">**</span>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">reader_config</span><span class="o">=</span><span class="p">{</span><span class="s2">&quot;sample_list_generator&quot;</span><span class="p">:</span> <span class="n">some_sample_list_generator</span><span class="p">}</span>
</pre></div> </pre></div>
</div> </div>
<ol class="simple"> <div class="highlight-guess"><div class="highlight"><pre><span></span> <span class="n">reader_config</span><span class="o">=</span><span class="err">{</span><span class="ss">&quot;batch_generator&quot;</span><span class="p">:</span> <span class="n">some_batch_genrator</span><span class="err">}</span>
<li><strong>batch generator:</strong></li>
</ol> <span class="n">The</span> <span class="n">trial</span> <span class="k">to</span> <span class="n">parse</span> <span class="n">config</span> <span class="n">will</span> <span class="n">be</span> <span class="k">in</span> <span class="n">the</span> <span class="k">order</span> <span class="k">of</span> <span class="mi">1</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="mi">3</span><span class="p">),</span> <span class="k">and</span> <span class="k">any</span> <span class="n">other</span> <span class="n">unrelated</span> <span class="n">keys</span> <span class="k">in</span> <span class="n">these</span> <span class="n">configs</span> <span class="n">will</span> <span class="n">be</span> <span class="n">ignored</span><span class="p">.</span>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">reader_config</span><span class="o">=</span><span class="p">{</span><span class="s2">&quot;batch_generator&quot;</span><span class="p">:</span> <span class="n">some_batch_genrator</span><span class="p">}</span>
</pre></div> </pre></div>
</div> </div>
<p>The trial to parse config will be in the order of 1) -&gt; 3), and any other unrelated keys in these configs will be ignored.</p>
</li> </li>
<li><p class="first"><strong>exe (fluid.Executor):</strong> The executor to run the input program.</p> <li><p class="first"><strong>exe (fluid.Executor):</strong> The executor to run the input program.</p>
</li> </li>
<li><p class="first"><strong>buf_size (int):</strong> The size of buffers for data reader and knowledge <li><p class="first"><strong>buf_size (int):</strong> The size of buffers for data reader and knowledge
writer on each device.</p> .. code-block:: guess</p>
<blockquote>
<div><p>writer on each device.</p>
</div></blockquote>
</li> </li>
<li><p class="first"><strong>times (int):</strong> The maximum repeated serving times, default 1. Whenever <li><p class="first"><strong>times (int):</strong> The maximum repeated serving times, default 1. Whenever
the public method <strong>get_knowledge_generator()</strong> in <strong>Student</strong> .. code-block:: guess</p>
<blockquote>
<div><p>the public method <strong>get_knowledge_generator()</strong> in <strong>Student</strong>
object called once, the serving times will be added one, object called once, the serving times will be added one,
until reaching the maximum and ending the service.</p> until reaching the maximum and ending the service. Only
valid in online mode, and will be ignored in offline mode.</p>
</div></blockquote>
</li> </li>
</ul> </ul>
<p><strong>Return:</strong> None</p> <p><strong>Return:</strong> None</p>
...@@ -271,15 +292,21 @@ until reaching the maximum and ending the service.</p> ...@@ -271,15 +292,21 @@ until reaching the maximum and ending the service.</p>
<span class="n">exe</span><span class="o">=</span><span class="n">exe</span><span class="p">)</span> <span class="n">exe</span><span class="o">=</span><span class="n">exe</span><span class="p">)</span>
</pre></div> </pre></div>
</div> </div>
<p>!!! note &#8220;Note&#8220; <dl class="docutils">
This example should be run with the example of class <strong>Student</strong>.</p> <dt>!!! note &#8220;Note&#8221;</dt>
<dd>This example should be run with the example of class <strong>Student</strong>.</dd>
</dl>
</div> </div>
<div class="section" id="student"> <div class="section" id="student">
<h2>Student<a class="headerlink" href="#student" title="永久链接至标题"></a></h2> <h2>Student<a class="headerlink" href="#student" title="永久链接至标题"></a></h2>
<p>pantheon.Student(merge_strategy=None) <a class="reference external" href="https://github.com/PaddlePaddle/PaddleSlim/blob/develop/paddleslim/pantheon/student.py#L34">source</a></p> <p>pantheon.Student(merge_strategy=None) <a class="reference external" href="https://github.com/PaddlePaddle/PaddleSlim/blob/develop/paddleslim/pantheon/student.py#L34">source</a></p>
<p>: The class defined for the student model. Receive knowledge data from <dl class="docutils">
teacher model and carry out knowledge merging.</p> <dt>: The class defined for the student model. Receive knowledge data from</dt>
<p><strong>Args:</strong></p> <dd><blockquote class="first">
<div>teacher model and carry out knowledge merging.</div></blockquote>
<p class="last"><strong>Args:</strong></p>
</dd>
</dl>
<ul class="simple"> <ul class="simple">
<li><strong>merge_strategy (dict|None):</strong> - A dict whose keys are the common schemas shared by different teachers, and each corresponding value specifies the merging strategy for different schemas respectively, supporting <strong>sum</strong> and <strong>mean</strong> now.</li> <li><strong>merge_strategy (dict|None):</strong> - A dict whose keys are the common schemas shared by different teachers, and each corresponding value specifies the merging strategy for different schemas respectively, supporting <strong>sum</strong> and <strong>mean</strong> now.</li>
</ul> </ul>
...@@ -289,11 +316,11 @@ teacher model and carry out knowledge merging.</p> ...@@ -289,11 +316,11 @@ teacher model and carry out knowledge merging.</p>
<p><strong>Args:</strong></p> <p><strong>Args:</strong></p>
<ul class="simple"> <ul class="simple">
<li><strong>in_path (str|None):</strong> The input file path. Default None.</li> <li><strong>in_path (str|None):</strong> The input file path. Default None.</li>
<li><strong>in_address (str|None):</strong> The input IP address, in the format &#8220;&lt;IP_address&gt;:&lt;IP_port&gt;&#8220; (e.g. &#8220;127.0.0.1:8080&#8220;). Default None.</li> <li><strong>in_address (str|None):</strong> The input IP address, in the format &#8220;&amp;lt;IP_address&amp;gt;:&amp;lt;IP_port&amp;gt;&#8221; (e.g. &#8220;127.0.0.1:8080&#8221;). Default None.</li>
</ul> </ul>
<p><strong>Return:</strong> None</p> <p><strong>Return:</strong> None</p>
<p>pantheon.Student.start() <a class="reference external" href="https://github.com/PaddlePaddle/PaddleSlim/blob/develop/paddleslim/pantheon/student.py#L213">source</a></p> <p>pantheon.Student.start() <a class="reference external" href="https://github.com/PaddlePaddle/PaddleSlim/blob/develop/paddleslim/pantheon/student.py#L213">source</a></p>
<p>: End teachers&#8216; registration and synchronize with all of them.</p> <p>: End teachers&#8217; registration and synchronize with all of them.</p>
<p><strong>Args:</strong> None</p> <p><strong>Args:</strong> None</p>
<p><strong>Return:</strong> None</p> <p><strong>Return:</strong> None</p>
<p>pantheon.Student.send(self, data, teacher_ids=None) <a class="reference external" href="https://github.com/PaddlePaddle/PaddleSlim/blob/develop/paddleslim/pantheon/student.py#L240">source</a></p> <p>pantheon.Student.send(self, data, teacher_ids=None) <a class="reference external" href="https://github.com/PaddlePaddle/PaddleSlim/blob/develop/paddleslim/pantheon/student.py#L240">source</a></p>
...@@ -306,7 +333,8 @@ teacher model and carry out knowledge merging.</p> ...@@ -306,7 +333,8 @@ teacher model and carry out knowledge merging.</p>
<p><strong>Return:</strong> None</p> <p><strong>Return:</strong> None</p>
<p>pantheon.Student.recv(teacher_id) <a class="reference external" href="https://github.com/PaddlePaddle/PaddleSlim/blob/develop/paddleslim/pantheon/student.py#L262">source</a></p> <p>pantheon.Student.recv(teacher_id) <a class="reference external" href="https://github.com/PaddlePaddle/PaddleSlim/blob/develop/paddleslim/pantheon/student.py#L262">source</a></p>
<p>: Receive data from one teacher.</p> <p>: Receive data from one teacher.</p>
<p><strong>Args:</strong></p> <blockquote>
<div><strong>Args:</strong></div></blockquote>
<ul class="simple"> <ul class="simple">
<li><strong>teacher_id (int):</strong> - The id of teacher that receives data from.</li> <li><strong>teacher_id (int):</strong> - The id of teacher that receives data from.</li>
</ul> </ul>
...@@ -315,25 +343,31 @@ teacher model and carry out knowledge merging.</p> ...@@ -315,25 +343,31 @@ teacher model and carry out knowledge merging.</p>
<li>The received data object.</li> <li>The received data object.</li>
</ul> </ul>
<p>pantheon.Student.get_knowledge_desc() <a class="reference external" href="https://github.com/PaddlePaddle/PaddleSlim/blob/develop/paddleslim/pantheon/student.py#L283">source</a></p> <p>pantheon.Student.get_knowledge_desc() <a class="reference external" href="https://github.com/PaddlePaddle/PaddleSlim/blob/develop/paddleslim/pantheon/student.py#L283">source</a></p>
<p>: Get description for knowledge, including shape, data type and lod level for each schema.</p> <blockquote>
<div><p>: Get description for knowledge, including shape, data type and lod level for each schema.</p>
<p><strong>Args:</strong> None</p> <p><strong>Args:</strong> None</p>
<p><strong>Return:</strong></p> <p><strong>Return:</strong></p>
</div></blockquote>
<ul class="simple"> <ul class="simple">
<li>Knowledge description, which is a dict.</li> <li>Knowledge description, which is a dict.</li>
</ul> </ul>
<p>pantheon.Student.get_knowledge_qsize() <a class="reference external" href="https://github.com/PaddlePaddle/PaddleSlim/blob/develop/paddleslim/pantheon/student.py#L318">source</a></p> <p>pantheon.Student.get_knowledge_qsize() <a class="reference external" href="https://github.com/PaddlePaddle/PaddleSlim/blob/develop/paddleslim/pantheon/student.py#L318">source</a></p>
<p>: Get the real-time size of knowledge queue. If this size is denoted as <blockquote>
<strong>qsize</strong>, it means that there are <strong>qsize</strong> batch knowledge data <div><dl class="docutils">
<dt>: Get the real-time size of knowledge queue. If this size is denoted as</dt>
<dd><strong>qsize</strong>, it means that there are <strong>qsize</strong> batch knowledge data
already pushed into knowledge queue and waiting for the knowledge already pushed into knowledge queue and waiting for the knowledge
generator to pop out. It&#8216;s dynamic and limited up to 100, the capacity generator to pop out. It&#8217;s dynamic and limited up to 100, the capacity
of the knowledge queue.</p> of the knowledge queue.</dd>
</dl>
<p><strong>Args:</strong> None</p> <p><strong>Args:</strong> None</p>
<p><strong>Return:</strong></p> <p><strong>Return:</strong></p>
</div></blockquote>
<ul class="simple"> <ul class="simple">
<li>The real-time size of knowledge queue.</li> <li>The real-time size of knowledge queue.</li>
</ul> </ul>
<p>pantheon.Student.get_knowledge_generator(batch_size, drop_last=False) <a class="reference external" href="https://github.com/PaddlePaddle/PaddleSlim/blob/develop/paddleslim/pantheon/student.py#L334">source</a></p> <p>pantheon.Student.get_knowledge_generator(batch_size, drop_last=False) <a class="reference external" href="https://github.com/PaddlePaddle/PaddleSlim/blob/develop/paddleslim/pantheon/student.py#L334">source</a></p>
<p>: Get the generator for knowledge data, return None if last generator doesn&#8216;t finish yet.</p> <p>: Get the generator for knowledge data, return None if last generator doesn&#8217;t finish yet.</p>
<p><strong>Args:</strong></p> <p><strong>Args:</strong></p>
<ul class="simple"> <ul class="simple">
<li><strong>batch_size (int):</strong> - The batch size of returned knowledge data.</li> <li><strong>batch_size (int):</strong> - The batch size of returned knowledge data.</li>
...@@ -364,8 +398,10 @@ of the knowledge queue.</p> ...@@ -364,8 +398,10 @@ of the knowledge queue.</p>
<span class="c1"># do something else</span> <span class="c1"># do something else</span>
</pre></div> </pre></div>
</div> </div>
<p>!!! note &#8220;Note&#8220; <dl class="docutils">
This example should be run with the example of class <strong>Teacher</strong>.</p> <dt>!!! note &#8220;Note&#8221;</dt>
<dd>This example should be run with the example of class <strong>Teacher</strong>.</dd>
</dl>
</div> </div>
</div> </div>
......
...@@ -36,7 +36,7 @@ ...@@ -36,7 +36,7 @@
<link rel="top" title="PaddleSlim 1.0 文档" href="../index.html"/> <link rel="top" title="PaddleSlim 1.0 文档" href="../index.html"/>
<link rel="up" title="API文档" href="index.html"/> <link rel="up" title="API文档" href="index.html"/>
<link rel="next" title="量化" href="quantization_api.html"/> <link rel="next" title="量化" href="quantization_api.html"/>
<link rel="prev" title="多进程蒸馏" href="pantheon_api.html"/> <link rel="prev" title="大规模可扩展知识蒸馏框架 Pantheon" href="pantheon_api.html"/>
<script src="../_static/js/modernizr.min.js"></script> <script src="../_static/js/modernizr.min.js"></script>
...@@ -83,7 +83,7 @@ ...@@ -83,7 +83,7 @@
<ul class="current"> <ul class="current">
<li class="toctree-l1"><a class="reference internal" href="../index_en.html">English Documents</a></li> <li class="toctree-l1"><a class="reference internal" href="../index_en.html">English Documents</a></li>
<li class="toctree-l1"><a class="reference internal" href="../intro.html">PaddleSlim简介</a></li> <li class="toctree-l1"><a class="reference internal" href="../intro.html">介绍</a></li>
<li class="toctree-l1"><a class="reference internal" href="../install.html">安装</a></li> <li class="toctree-l1"><a class="reference internal" href="../install.html">安装</a></li>
<li class="toctree-l1"><a class="reference internal" href="../quick_start/index.html">快速开始</a></li> <li class="toctree-l1"><a class="reference internal" href="../quick_start/index.html">快速开始</a></li>
<li class="toctree-l1"><a class="reference internal" href="../tutorials/index.html">进阶教程</a></li> <li class="toctree-l1"><a class="reference internal" href="../tutorials/index.html">进阶教程</a></li>
...@@ -91,7 +91,7 @@ ...@@ -91,7 +91,7 @@
<li class="toctree-l2"><a class="reference internal" href="analysis_api.html">模型分析</a></li> <li class="toctree-l2"><a class="reference internal" href="analysis_api.html">模型分析</a></li>
<li class="toctree-l2"><a class="reference internal" href="nas_api.html">SA-NAS</a></li> <li class="toctree-l2"><a class="reference internal" href="nas_api.html">SA-NAS</a></li>
<li class="toctree-l2"><a class="reference internal" href="one_shot_api.html">OneShotNAS</a></li> <li class="toctree-l2"><a class="reference internal" href="one_shot_api.html">OneShotNAS</a></li>
<li class="toctree-l2"><a class="reference internal" href="pantheon_api.html">多进程蒸馏</a></li> <li class="toctree-l2"><a class="reference internal" href="pantheon_api.html">大规模可扩展知识蒸馏框架 Pantheon</a></li>
<li class="toctree-l2 current"><a class="current reference internal" href="#">卷积层通道剪裁</a><ul> <li class="toctree-l2 current"><a class="current reference internal" href="#">卷积层通道剪裁</a><ul>
<li class="toctree-l3"><a class="reference internal" href="#pruner">Pruner</a></li> <li class="toctree-l3"><a class="reference internal" href="#pruner">Pruner</a></li>
<li class="toctree-l3"><a class="reference internal" href="#sensitivity">sensitivity</a></li> <li class="toctree-l3"><a class="reference internal" href="#sensitivity">sensitivity</a></li>
...@@ -499,7 +499,7 @@ ...@@ -499,7 +499,7 @@
<span class="p">}</span> <span class="p">}</span>
<span class="p">}</span> <span class="p">}</span>
<span class="n">sensitivities_file</span> <span class="o">=</span> <span class="s2">&quot;sensitive_api_demo.data&quot;</span> <span class="n">sensitivities_file</span> <span class="o">=</span> <span class="s2">&quot;sensitive_api_demo.data&quot;</span>
<span class="k">with</span> <span class="nb">open</span><span class="p">(</span><span class="n">sensitivities_file</span><span class="p">,</span> <span class="s1">&#39;w&#39;</span><span class="p">)</span> <span class="k">as</span> <span class="n">f</span><span class="p">:</span> <span class="k">with</span> <span class="nb">open</span><span class="p">(</span><span class="n">sensitivities_file</span><span class="p">,</span> <span class="s1">&#39;wb&#39;</span><span class="p">)</span> <span class="k">as</span> <span class="n">f</span><span class="p">:</span>
<span class="n">pickle</span><span class="o">.</span><span class="n">dump</span><span class="p">(</span><span class="n">sen</span><span class="p">,</span> <span class="n">f</span><span class="p">)</span> <span class="n">pickle</span><span class="o">.</span><span class="n">dump</span><span class="p">(</span><span class="n">sen</span><span class="p">,</span> <span class="n">f</span><span class="p">)</span>
<span class="n">sensitivities</span> <span class="o">=</span> <span class="n">load_sensitivities</span><span class="p">(</span><span class="n">sensitivities_file</span><span class="p">)</span> <span class="n">sensitivities</span> <span class="o">=</span> <span class="n">load_sensitivities</span><span class="p">(</span><span class="n">sensitivities_file</span><span class="p">)</span>
<span class="nb">print</span><span class="p">(</span><span class="n">sensitivities</span><span class="p">)</span> <span class="nb">print</span><span class="p">(</span><span class="n">sensitivities</span><span class="p">)</span>
...@@ -553,7 +553,7 @@ ...@@ -553,7 +553,7 @@
<a href="quantization_api.html" class="btn btn-neutral float-right" title="量化" accesskey="n">Next <span class="fa fa-arrow-circle-right"></span></a> <a href="quantization_api.html" class="btn btn-neutral float-right" title="量化" accesskey="n">Next <span class="fa fa-arrow-circle-right"></span></a>
<a href="pantheon_api.html" class="btn btn-neutral" title="多进程蒸馏" accesskey="p"><span class="fa fa-arrow-circle-left"></span> Previous</a> <a href="pantheon_api.html" class="btn btn-neutral" title="大规模可扩展知识蒸馏框架 Pantheon" accesskey="p"><span class="fa fa-arrow-circle-left"></span> Previous</a>
</div> </div>
......
...@@ -83,7 +83,7 @@ ...@@ -83,7 +83,7 @@
<ul class="current"> <ul class="current">
<li class="toctree-l1"><a class="reference internal" href="../index_en.html">English Documents</a></li> <li class="toctree-l1"><a class="reference internal" href="../index_en.html">English Documents</a></li>
<li class="toctree-l1"><a class="reference internal" href="../intro.html">PaddleSlim简介</a></li> <li class="toctree-l1"><a class="reference internal" href="../intro.html">介绍</a></li>
<li class="toctree-l1"><a class="reference internal" href="../install.html">安装</a></li> <li class="toctree-l1"><a class="reference internal" href="../install.html">安装</a></li>
<li class="toctree-l1"><a class="reference internal" href="../quick_start/index.html">快速开始</a></li> <li class="toctree-l1"><a class="reference internal" href="../quick_start/index.html">快速开始</a></li>
<li class="toctree-l1"><a class="reference internal" href="../tutorials/index.html">进阶教程</a></li> <li class="toctree-l1"><a class="reference internal" href="../tutorials/index.html">进阶教程</a></li>
...@@ -91,7 +91,7 @@ ...@@ -91,7 +91,7 @@
<li class="toctree-l2"><a class="reference internal" href="analysis_api.html">模型分析</a></li> <li class="toctree-l2"><a class="reference internal" href="analysis_api.html">模型分析</a></li>
<li class="toctree-l2"><a class="reference internal" href="nas_api.html">SA-NAS</a></li> <li class="toctree-l2"><a class="reference internal" href="nas_api.html">SA-NAS</a></li>
<li class="toctree-l2"><a class="reference internal" href="one_shot_api.html">OneShotNAS</a></li> <li class="toctree-l2"><a class="reference internal" href="one_shot_api.html">OneShotNAS</a></li>
<li class="toctree-l2"><a class="reference internal" href="pantheon_api.html">多进程蒸馏</a></li> <li class="toctree-l2"><a class="reference internal" href="pantheon_api.html">大规模可扩展知识蒸馏框架 Pantheon</a></li>
<li class="toctree-l2"><a class="reference internal" href="prune_api.html">卷积层通道剪裁</a></li> <li class="toctree-l2"><a class="reference internal" href="prune_api.html">卷积层通道剪裁</a></li>
<li class="toctree-l2 current"><a class="current reference internal" href="#">量化</a><ul> <li class="toctree-l2 current"><a class="current reference internal" href="#">量化</a><ul>
<li class="toctree-l3"><a class="reference internal" href="#id2">量化配置</a></li> <li class="toctree-l3"><a class="reference internal" href="#id2">量化配置</a></li>
......
...@@ -83,7 +83,7 @@ ...@@ -83,7 +83,7 @@
<ul class="current"> <ul class="current">
<li class="toctree-l1"><a class="reference internal" href="../index_en.html">English Documents</a></li> <li class="toctree-l1"><a class="reference internal" href="../index_en.html">English Documents</a></li>
<li class="toctree-l1"><a class="reference internal" href="../intro.html">PaddleSlim简介</a></li> <li class="toctree-l1"><a class="reference internal" href="../intro.html">介绍</a></li>
<li class="toctree-l1"><a class="reference internal" href="../install.html">安装</a></li> <li class="toctree-l1"><a class="reference internal" href="../install.html">安装</a></li>
<li class="toctree-l1"><a class="reference internal" href="../quick_start/index.html">快速开始</a></li> <li class="toctree-l1"><a class="reference internal" href="../quick_start/index.html">快速开始</a></li>
<li class="toctree-l1"><a class="reference internal" href="../tutorials/index.html">进阶教程</a></li> <li class="toctree-l1"><a class="reference internal" href="../tutorials/index.html">进阶教程</a></li>
...@@ -91,7 +91,7 @@ ...@@ -91,7 +91,7 @@
<li class="toctree-l2"><a class="reference internal" href="analysis_api.html">模型分析</a></li> <li class="toctree-l2"><a class="reference internal" href="analysis_api.html">模型分析</a></li>
<li class="toctree-l2"><a class="reference internal" href="nas_api.html">SA-NAS</a></li> <li class="toctree-l2"><a class="reference internal" href="nas_api.html">SA-NAS</a></li>
<li class="toctree-l2"><a class="reference internal" href="one_shot_api.html">OneShotNAS</a></li> <li class="toctree-l2"><a class="reference internal" href="one_shot_api.html">OneShotNAS</a></li>
<li class="toctree-l2"><a class="reference internal" href="pantheon_api.html">多进程蒸馏</a></li> <li class="toctree-l2"><a class="reference internal" href="pantheon_api.html">大规模可扩展知识蒸馏框架 Pantheon</a></li>
<li class="toctree-l2"><a class="reference internal" href="prune_api.html">卷积层通道剪裁</a></li> <li class="toctree-l2"><a class="reference internal" href="prune_api.html">卷积层通道剪裁</a></li>
<li class="toctree-l2"><a class="reference internal" href="quantization_api.html">量化</a></li> <li class="toctree-l2"><a class="reference internal" href="quantization_api.html">量化</a></li>
<li class="toctree-l2"><a class="reference internal" href="single_distiller_api.html">简单蒸馏</a></li> <li class="toctree-l2"><a class="reference internal" href="single_distiller_api.html">简单蒸馏</a></li>
......
...@@ -83,7 +83,7 @@ ...@@ -83,7 +83,7 @@
<ul class="current"> <ul class="current">
<li class="toctree-l1"><a class="reference internal" href="../index_en.html">English Documents</a></li> <li class="toctree-l1"><a class="reference internal" href="../index_en.html">English Documents</a></li>
<li class="toctree-l1"><a class="reference internal" href="../intro.html">PaddleSlim简介</a></li> <li class="toctree-l1"><a class="reference internal" href="../intro.html">介绍</a></li>
<li class="toctree-l1"><a class="reference internal" href="../install.html">安装</a></li> <li class="toctree-l1"><a class="reference internal" href="../install.html">安装</a></li>
<li class="toctree-l1"><a class="reference internal" href="../quick_start/index.html">快速开始</a></li> <li class="toctree-l1"><a class="reference internal" href="../quick_start/index.html">快速开始</a></li>
<li class="toctree-l1"><a class="reference internal" href="../tutorials/index.html">进阶教程</a></li> <li class="toctree-l1"><a class="reference internal" href="../tutorials/index.html">进阶教程</a></li>
...@@ -91,7 +91,7 @@ ...@@ -91,7 +91,7 @@
<li class="toctree-l2"><a class="reference internal" href="analysis_api.html">模型分析</a></li> <li class="toctree-l2"><a class="reference internal" href="analysis_api.html">模型分析</a></li>
<li class="toctree-l2"><a class="reference internal" href="nas_api.html">SA-NAS</a></li> <li class="toctree-l2"><a class="reference internal" href="nas_api.html">SA-NAS</a></li>
<li class="toctree-l2"><a class="reference internal" href="one_shot_api.html">OneShotNAS</a></li> <li class="toctree-l2"><a class="reference internal" href="one_shot_api.html">OneShotNAS</a></li>
<li class="toctree-l2"><a class="reference internal" href="pantheon_api.html">多进程蒸馏</a></li> <li class="toctree-l2"><a class="reference internal" href="pantheon_api.html">大规模可扩展知识蒸馏框架 Pantheon</a></li>
<li class="toctree-l2"><a class="reference internal" href="prune_api.html">卷积层通道剪裁</a></li> <li class="toctree-l2"><a class="reference internal" href="prune_api.html">卷积层通道剪裁</a></li>
<li class="toctree-l2"><a class="reference internal" href="quantization_api.html">量化</a></li> <li class="toctree-l2"><a class="reference internal" href="quantization_api.html">量化</a></li>
<li class="toctree-l2 current"><a class="current reference internal" href="#">简单蒸馏</a><ul> <li class="toctree-l2 current"><a class="current reference internal" href="#">简单蒸馏</a><ul>
......
...@@ -83,7 +83,7 @@ ...@@ -83,7 +83,7 @@
<ul class="current"> <ul class="current">
<li class="toctree-l1"><a class="reference internal" href="../index_en.html">English Documents</a></li> <li class="toctree-l1"><a class="reference internal" href="../index_en.html">English Documents</a></li>
<li class="toctree-l1"><a class="reference internal" href="../intro.html">PaddleSlim简介</a></li> <li class="toctree-l1"><a class="reference internal" href="../intro.html">介绍</a></li>
<li class="toctree-l1"><a class="reference internal" href="../install.html">安装</a></li> <li class="toctree-l1"><a class="reference internal" href="../install.html">安装</a></li>
<li class="toctree-l1"><a class="reference internal" href="../quick_start/index.html">快速开始</a></li> <li class="toctree-l1"><a class="reference internal" href="../quick_start/index.html">快速开始</a></li>
<li class="toctree-l1"><a class="reference internal" href="../tutorials/index.html">进阶教程</a></li> <li class="toctree-l1"><a class="reference internal" href="../tutorials/index.html">进阶教程</a></li>
...@@ -91,7 +91,7 @@ ...@@ -91,7 +91,7 @@
<li class="toctree-l2"><a class="reference internal" href="analysis_api.html">模型分析</a></li> <li class="toctree-l2"><a class="reference internal" href="analysis_api.html">模型分析</a></li>
<li class="toctree-l2"><a class="reference internal" href="nas_api.html">SA-NAS</a></li> <li class="toctree-l2"><a class="reference internal" href="nas_api.html">SA-NAS</a></li>
<li class="toctree-l2"><a class="reference internal" href="one_shot_api.html">OneShotNAS</a></li> <li class="toctree-l2"><a class="reference internal" href="one_shot_api.html">OneShotNAS</a></li>
<li class="toctree-l2"><a class="reference internal" href="pantheon_api.html">多进程蒸馏</a></li> <li class="toctree-l2"><a class="reference internal" href="pantheon_api.html">大规模可扩展知识蒸馏框架 Pantheon</a></li>
<li class="toctree-l2"><a class="reference internal" href="prune_api.html">卷积层通道剪裁</a></li> <li class="toctree-l2"><a class="reference internal" href="prune_api.html">卷积层通道剪裁</a></li>
<li class="toctree-l2"><a class="reference internal" href="quantization_api.html">量化</a></li> <li class="toctree-l2"><a class="reference internal" href="quantization_api.html">量化</a></li>
<li class="toctree-l2"><a class="reference internal" href="single_distiller_api.html">简单蒸馏</a></li> <li class="toctree-l2"><a class="reference internal" href="single_distiller_api.html">简单蒸馏</a></li>
......
...@@ -35,7 +35,7 @@ ...@@ -35,7 +35,7 @@
<link rel="search" title="Search" href="../search.html"/> <link rel="search" title="Search" href="../search.html"/>
<link rel="top" title="PaddleSlim 1.0 documentation" href="../index.html"/> <link rel="top" title="PaddleSlim 1.0 documentation" href="../index.html"/>
<link rel="next" title="paddleslim.analysis package" href="paddleslim.analysis.html"/> <link rel="next" title="paddleslim.analysis package" href="paddleslim.analysis.html"/>
<link rel="prev" title="Pruning of image classification model - sensitivity" href="../tutorials/sensitivity_tutorial_en.html"/> <link rel="prev" title="Pruning of image classification model - sensitivity" href="../tutorials/image_classification_sensitivity_analysis_tutorial_en.html"/>
<script src="../_static/js/modernizr.min.js"></script> <script src="../_static/js/modernizr.min.js"></script>
...@@ -95,6 +95,7 @@ ...@@ -95,6 +95,7 @@
<li class="toctree-l2"><a class="reference internal" href="paddleslim.nas.one_shot.html">paddleslim.nas.one_shot package</a></li> <li class="toctree-l2"><a class="reference internal" href="paddleslim.nas.one_shot.html">paddleslim.nas.one_shot package</a></li>
<li class="toctree-l2"><a class="reference internal" href="paddleslim.pantheon.html">paddleslim.pantheon package</a></li> <li class="toctree-l2"><a class="reference internal" href="paddleslim.pantheon.html">paddleslim.pantheon package</a></li>
<li class="toctree-l2"><a class="reference internal" href="search_space_en.html">search space</a></li> <li class="toctree-l2"><a class="reference internal" href="search_space_en.html">search space</a></li>
<li class="toctree-l2"><a class="reference internal" href="table_latency_en.html">Table about hardware lantency</a></li>
</ul> </ul>
</li> </li>
<li class="toctree-l1"><a class="reference internal" href="../model_zoo_en.html">Model Zoo</a></li> <li class="toctree-l1"><a class="reference internal" href="../model_zoo_en.html">Model Zoo</a></li>
...@@ -154,6 +155,7 @@ ...@@ -154,6 +155,7 @@
<li class="toctree-l1"><a class="reference internal" href="paddleslim.nas.one_shot.html">paddleslim.nas.one_shot package</a></li> <li class="toctree-l1"><a class="reference internal" href="paddleslim.nas.one_shot.html">paddleslim.nas.one_shot package</a></li>
<li class="toctree-l1"><a class="reference internal" href="paddleslim.pantheon.html">paddleslim.pantheon package</a></li> <li class="toctree-l1"><a class="reference internal" href="paddleslim.pantheon.html">paddleslim.pantheon package</a></li>
<li class="toctree-l1"><a class="reference internal" href="search_space_en.html">search space</a></li> <li class="toctree-l1"><a class="reference internal" href="search_space_en.html">search space</a></li>
<li class="toctree-l1"><a class="reference internal" href="table_latency_en.html">Table about hardware lantency</a></li>
</ul> </ul>
</div> </div>
</div> </div>
...@@ -168,7 +170,7 @@ ...@@ -168,7 +170,7 @@
<a href="paddleslim.analysis.html" class="btn btn-neutral float-right" title="paddleslim.analysis package" accesskey="n">Next <span class="fa fa-arrow-circle-right"></span></a> <a href="paddleslim.analysis.html" class="btn btn-neutral float-right" title="paddleslim.analysis package" accesskey="n">Next <span class="fa fa-arrow-circle-right"></span></a>
<a href="../tutorials/sensitivity_tutorial_en.html" class="btn btn-neutral" title="Pruning of image classification model - sensitivity" accesskey="p"><span class="fa fa-arrow-circle-left"></span> Previous</a> <a href="../tutorials/image_classification_sensitivity_analysis_tutorial_en.html" class="btn btn-neutral" title="Pruning of image classification model - sensitivity" accesskey="p"><span class="fa fa-arrow-circle-left"></span> Previous</a>
</div> </div>
......
...@@ -102,6 +102,7 @@ ...@@ -102,6 +102,7 @@
<li class="toctree-l2"><a class="reference internal" href="paddleslim.nas.one_shot.html">paddleslim.nas.one_shot package</a></li> <li class="toctree-l2"><a class="reference internal" href="paddleslim.nas.one_shot.html">paddleslim.nas.one_shot package</a></li>
<li class="toctree-l2"><a class="reference internal" href="paddleslim.pantheon.html">paddleslim.pantheon package</a></li> <li class="toctree-l2"><a class="reference internal" href="paddleslim.pantheon.html">paddleslim.pantheon package</a></li>
<li class="toctree-l2"><a class="reference internal" href="search_space_en.html">search space</a></li> <li class="toctree-l2"><a class="reference internal" href="search_space_en.html">search space</a></li>
<li class="toctree-l2"><a class="reference internal" href="table_latency_en.html">Table about hardware lantency</a></li>
</ul> </ul>
</li> </li>
<li class="toctree-l1"><a class="reference internal" href="../model_zoo_en.html">Model Zoo</a></li> <li class="toctree-l1"><a class="reference internal" href="../model_zoo_en.html">Model Zoo</a></li>
......
...@@ -100,6 +100,7 @@ ...@@ -100,6 +100,7 @@
<li class="toctree-l2"><a class="reference internal" href="paddleslim.nas.one_shot.html">paddleslim.nas.one_shot package</a></li> <li class="toctree-l2"><a class="reference internal" href="paddleslim.nas.one_shot.html">paddleslim.nas.one_shot package</a></li>
<li class="toctree-l2"><a class="reference internal" href="paddleslim.pantheon.html">paddleslim.pantheon package</a></li> <li class="toctree-l2"><a class="reference internal" href="paddleslim.pantheon.html">paddleslim.pantheon package</a></li>
<li class="toctree-l2"><a class="reference internal" href="search_space_en.html">search space</a></li> <li class="toctree-l2"><a class="reference internal" href="search_space_en.html">search space</a></li>
<li class="toctree-l2"><a class="reference internal" href="table_latency_en.html">Table about hardware lantency</a></li>
</ul> </ul>
</li> </li>
<li class="toctree-l1"><a class="reference internal" href="../model_zoo_en.html">Model Zoo</a></li> <li class="toctree-l1"><a class="reference internal" href="../model_zoo_en.html">Model Zoo</a></li>
......
...@@ -104,6 +104,7 @@ ...@@ -104,6 +104,7 @@
<li class="toctree-l2"><a class="reference internal" href="paddleslim.nas.one_shot.html">paddleslim.nas.one_shot package</a></li> <li class="toctree-l2"><a class="reference internal" href="paddleslim.nas.one_shot.html">paddleslim.nas.one_shot package</a></li>
<li class="toctree-l2"><a class="reference internal" href="paddleslim.pantheon.html">paddleslim.pantheon package</a></li> <li class="toctree-l2"><a class="reference internal" href="paddleslim.pantheon.html">paddleslim.pantheon package</a></li>
<li class="toctree-l2"><a class="reference internal" href="search_space_en.html">search space</a></li> <li class="toctree-l2"><a class="reference internal" href="search_space_en.html">search space</a></li>
<li class="toctree-l2"><a class="reference internal" href="table_latency_en.html">Table about hardware lantency</a></li>
</ul> </ul>
</li> </li>
<li class="toctree-l1"><a class="reference internal" href="../model_zoo_en.html">Model Zoo</a></li> <li class="toctree-l1"><a class="reference internal" href="../model_zoo_en.html">Model Zoo</a></li>
......
...@@ -101,6 +101,7 @@ ...@@ -101,6 +101,7 @@
</li> </li>
<li class="toctree-l2"><a class="reference internal" href="paddleslim.pantheon.html">paddleslim.pantheon package</a></li> <li class="toctree-l2"><a class="reference internal" href="paddleslim.pantheon.html">paddleslim.pantheon package</a></li>
<li class="toctree-l2"><a class="reference internal" href="search_space_en.html">search space</a></li> <li class="toctree-l2"><a class="reference internal" href="search_space_en.html">search space</a></li>
<li class="toctree-l2"><a class="reference internal" href="table_latency_en.html">Table about hardware lantency</a></li>
</ul> </ul>
</li> </li>
<li class="toctree-l1"><a class="reference internal" href="../model_zoo_en.html">Model Zoo</a></li> <li class="toctree-l1"><a class="reference internal" href="../model_zoo_en.html">Model Zoo</a></li>
......
...@@ -102,6 +102,7 @@ ...@@ -102,6 +102,7 @@
</ul> </ul>
</li> </li>
<li class="toctree-l2"><a class="reference internal" href="search_space_en.html">search space</a></li> <li class="toctree-l2"><a class="reference internal" href="search_space_en.html">search space</a></li>
<li class="toctree-l2"><a class="reference internal" href="table_latency_en.html">Table about hardware lantency</a></li>
</ul> </ul>
</li> </li>
<li class="toctree-l1"><a class="reference internal" href="../model_zoo_en.html">Model Zoo</a></li> <li class="toctree-l1"><a class="reference internal" href="../model_zoo_en.html">Model Zoo</a></li>
...@@ -270,7 +271,8 @@ writer on each device.</li> ...@@ -270,7 +271,8 @@ writer on each device.</li>
<li><strong>times</strong> (<em>int</em>) &#8211; The maximum repeated serving times. Default 1. Whenever <li><strong>times</strong> (<em>int</em>) &#8211; The maximum repeated serving times. Default 1. Whenever
the public method &#8216;get_knowledge_generator()&#8217; in Student the public method &#8216;get_knowledge_generator()&#8217; in Student
object called once, the serving times will be added one, object called once, the serving times will be added one,
until reaching the maximum and ending the service.</li> until reaching the maximum and ending the service. Only
valid in online mode, and will be ignored in offline mode.</li>
</ul> </ul>
</td> </td>
</tr> </tr>
...@@ -697,7 +699,8 @@ writer on each device.</li> ...@@ -697,7 +699,8 @@ writer on each device.</li>
<li><strong>times</strong> (<em>int</em>) &#8211; The maximum repeated serving times. Default 1. Whenever <li><strong>times</strong> (<em>int</em>) &#8211; The maximum repeated serving times. Default 1. Whenever
the public method &#8216;get_knowledge_generator()&#8217; in Student the public method &#8216;get_knowledge_generator()&#8217; in Student
object called once, the serving times will be added one, object called once, the serving times will be added one,
until reaching the maximum and ending the service.</li> until reaching the maximum and ending the service. Only
valid in online mode, and will be ignored in offline mode.</li>
</ul> </ul>
</td> </td>
</tr> </tr>
......
...@@ -105,6 +105,7 @@ ...@@ -105,6 +105,7 @@
<li class="toctree-l2"><a class="reference internal" href="paddleslim.nas.one_shot.html">paddleslim.nas.one_shot package</a></li> <li class="toctree-l2"><a class="reference internal" href="paddleslim.nas.one_shot.html">paddleslim.nas.one_shot package</a></li>
<li class="toctree-l2"><a class="reference internal" href="paddleslim.pantheon.html">paddleslim.pantheon package</a></li> <li class="toctree-l2"><a class="reference internal" href="paddleslim.pantheon.html">paddleslim.pantheon package</a></li>
<li class="toctree-l2"><a class="reference internal" href="search_space_en.html">search space</a></li> <li class="toctree-l2"><a class="reference internal" href="search_space_en.html">search space</a></li>
<li class="toctree-l2"><a class="reference internal" href="table_latency_en.html">Table about hardware lantency</a></li>
</ul> </ul>
</li> </li>
<li class="toctree-l1"><a class="reference internal" href="../model_zoo_en.html">Model Zoo</a></li> <li class="toctree-l1"><a class="reference internal" href="../model_zoo_en.html">Model Zoo</a></li>
......
...@@ -101,6 +101,7 @@ ...@@ -101,6 +101,7 @@
<li class="toctree-l2"><a class="reference internal" href="paddleslim.nas.one_shot.html">paddleslim.nas.one_shot package</a></li> <li class="toctree-l2"><a class="reference internal" href="paddleslim.nas.one_shot.html">paddleslim.nas.one_shot package</a></li>
<li class="toctree-l2"><a class="reference internal" href="paddleslim.pantheon.html">paddleslim.pantheon package</a></li> <li class="toctree-l2"><a class="reference internal" href="paddleslim.pantheon.html">paddleslim.pantheon package</a></li>
<li class="toctree-l2"><a class="reference internal" href="search_space_en.html">search space</a></li> <li class="toctree-l2"><a class="reference internal" href="search_space_en.html">search space</a></li>
<li class="toctree-l2"><a class="reference internal" href="table_latency_en.html">Table about hardware lantency</a></li>
</ul> </ul>
</li> </li>
<li class="toctree-l1"><a class="reference internal" href="../model_zoo_en.html">Model Zoo</a></li> <li class="toctree-l1"><a class="reference internal" href="../model_zoo_en.html">Model Zoo</a></li>
......
...@@ -35,7 +35,7 @@ ...@@ -35,7 +35,7 @@
<link rel="search" title="Search" href="../search.html"/> <link rel="search" title="Search" href="../search.html"/>
<link rel="top" title="PaddleSlim 1.0 documentation" href="../index.html"/> <link rel="top" title="PaddleSlim 1.0 documentation" href="../index.html"/>
<link rel="up" title="API Documents" href="index_en.html"/> <link rel="up" title="API Documents" href="index_en.html"/>
<link rel="next" title="Model Zoo" href="../model_zoo_en.html"/> <link rel="next" title="Table about hardware lantency" href="table_latency_en.html"/>
<link rel="prev" title="paddleslim.pantheon package" href="paddleslim.pantheon.html"/> <link rel="prev" title="paddleslim.pantheon package" href="paddleslim.pantheon.html"/>
...@@ -101,6 +101,7 @@ ...@@ -101,6 +101,7 @@
<li class="toctree-l3"><a class="reference internal" href="#how-to-write-yourself-search-space">How to write yourself search space</a></li> <li class="toctree-l3"><a class="reference internal" href="#how-to-write-yourself-search-space">How to write yourself search space</a></li>
</ul> </ul>
</li> </li>
<li class="toctree-l2"><a class="reference internal" href="table_latency_en.html">Table about hardware lantency</a></li>
</ul> </ul>
</li> </li>
<li class="toctree-l1"><a class="reference internal" href="../model_zoo_en.html">Model Zoo</a></li> <li class="toctree-l1"><a class="reference internal" href="../model_zoo_en.html">Model Zoo</a></li>
...@@ -280,7 +281,7 @@ return bn</dd> ...@@ -280,7 +281,7 @@ return bn</dd>
<div class="rst-footer-buttons" role="navigation" aria-label="footer navigation"> <div class="rst-footer-buttons" role="navigation" aria-label="footer navigation">
<a href="../model_zoo_en.html" class="btn btn-neutral float-right" title="Model Zoo" accesskey="n">Next <span class="fa fa-arrow-circle-right"></span></a> <a href="table_latency_en.html" class="btn btn-neutral float-right" title="Table about hardware lantency" accesskey="n">Next <span class="fa fa-arrow-circle-right"></span></a>
<a href="paddleslim.pantheon.html" class="btn btn-neutral" title="paddleslim.pantheon package" accesskey="p"><span class="fa fa-arrow-circle-left"></span> Previous</a> <a href="paddleslim.pantheon.html" class="btn btn-neutral" title="paddleslim.pantheon package" accesskey="p"><span class="fa fa-arrow-circle-left"></span> Previous</a>
......
<!DOCTYPE html>
<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]-->
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Table about hardware lantency &mdash; PaddleSlim 1.0 documentation</title>
<link rel="stylesheet" href="../_static/css/theme.css" type="text/css" />
<link rel="index" title="Index"
href="../genindex.html"/>
<link rel="search" title="Search" href="../search.html"/>
<link rel="top" title="PaddleSlim 1.0 documentation" href="../index.html"/>
<link rel="up" title="API Documents" href="index_en.html"/>
<link rel="next" title="Model Zoo" href="../model_zoo_en.html"/>
<link rel="prev" title="search space" href="search_space_en.html"/>
<script src="../_static/js/modernizr.min.js"></script>
</head>
<body class="wy-body-for-nav" role="document">
<div class="wy-grid-for-nav">
<nav data-toggle="wy-nav-shift" class="wy-nav-side">
<div class="wy-side-scroll">
<div class="wy-side-nav-search">
<a href="../index_en.html" class="icon icon-home"> PaddleSlim
</a>
<div role="search">
<form id="rtd-search-form" class="wy-form" action="../search.html" method="get">
<input type="text" name="q" placeholder="Search docs" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
</div>
</div>
<div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
<ul class="current">
<li class="toctree-l1"><a class="reference internal" href="../index.html">中文文档</a></li>
<li class="toctree-l1"><a class="reference internal" href="../intro_en.html">Introduction</a></li>
<li class="toctree-l1"><a class="reference internal" href="../install_en.html">Install</a></li>
<li class="toctree-l1"><a class="reference internal" href="../quick_start/index_en.html">Quick Start</a></li>
<li class="toctree-l1"><a class="reference internal" href="../tutorials/index_en.html">Aadvanced Tutorials</a></li>
<li class="toctree-l1 current"><a class="reference internal" href="index_en.html">API Documents</a><ul class="current">
<li class="toctree-l2"><a class="reference internal" href="paddleslim.analysis.html">paddleslim.analysis package</a></li>
<li class="toctree-l2"><a class="reference internal" href="paddleslim.prune.html">paddleslim.prune package</a></li>
<li class="toctree-l2"><a class="reference internal" href="paddleslim.dist.html">paddleslim.dist package</a></li>
<li class="toctree-l2"><a class="reference internal" href="paddleslim.quant.html">paddleslim.quant package</a></li>
<li class="toctree-l2"><a class="reference internal" href="paddleslim.nas.html">paddleslim.nas package</a></li>
<li class="toctree-l2"><a class="reference internal" href="paddleslim.nas.one_shot.html">paddleslim.nas.one_shot package</a></li>
<li class="toctree-l2"><a class="reference internal" href="paddleslim.pantheon.html">paddleslim.pantheon package</a></li>
<li class="toctree-l2"><a class="reference internal" href="search_space_en.html">search space</a></li>
<li class="toctree-l2 current"><a class="current reference internal" href="#">Table about hardware lantency</a><ul>
<li class="toctree-l3"><a class="reference internal" href="#introduce">Introduce</a></li>
<li class="toctree-l3"><a class="reference internal" href="#overview-format">Overview format</a></li>
<li class="toctree-l3"><a class="reference internal" href="#version">Version</a></li>
<li class="toctree-l3"><a class="reference internal" href="#operation">Operation</a><ul>
<li class="toctree-l4"><a class="reference internal" href="#conv2d">conv2d</a></li>
<li class="toctree-l4"><a class="reference internal" href="#activaiton">activaiton</a></li>
<li class="toctree-l4"><a class="reference internal" href="#batch-norm">batch_norm</a></li>
<li class="toctree-l4"><a class="reference internal" href="#eltwise">eltwise</a></li>
<li class="toctree-l4"><a class="reference internal" href="#pooling">pooling</a></li>
<li class="toctree-l4"><a class="reference internal" href="#softmax">softmax</a></li>
</ul>
</li>
</ul>
</li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../model_zoo_en.html">Model Zoo</a></li>
</ul>
</div>
</div>
</nav>
<section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">
<nav class="wy-nav-top" role="navigation" aria-label="top navigation">
<i data-toggle="wy-nav-top" class="fa fa-bars"></i>
<a href="../index_en.html">PaddleSlim</a>
</nav>
<div class="wy-nav-content">
<div class="rst-content">
<div role="navigation" aria-label="breadcrumbs navigation">
<ul class="wy-breadcrumbs">
<li><a href="../index_en.html">Docs</a> &raquo;</li>
<li><a href="index_en.html">API Documents</a> &raquo;</li>
<li>Table about hardware lantency</li>
<li class="wy-breadcrumbs-aside">
<a href="../_sources/api_en/table_latency_en.md.txt" rel="nofollow"> View page source</a>
</li>
</ul>
<hr/>
</div>
<div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
<div itemprop="articleBody">
<div class="section" id="table-about-hardware-lantency">
<h1>Table about hardware lantency<a class="headerlink" href="#table-about-hardware-lantency" title="Permalink to this headline"></a></h1>
<p>The table about hardware latency is used to evaluate the inference time in special environment and inference engine. The following text used to introduce the format that PaddleSlim support.</p>
<div class="section" id="introduce">
<h2>Introduce<a class="headerlink" href="#introduce" title="Permalink to this headline"></a></h2>
<p>The table about hardware latency saved all possible operations, one operation in the table including type and parameters, such as: type can be <code class="docutils literal"><span class="pre">conv2d</span></code>, and corresponding parameters can be the size of feature map, number of kernel, and the size of kernel.
The latency of every operation depends on hardware and inference engine.</p>
</div>
<div class="section" id="overview-format">
<h2>Overview format<a class="headerlink" href="#overview-format" title="Permalink to this headline"></a></h2>
<p>The table about hardware latency saved in the way of file or multi-line string.
The first line of the table about hardware latency saved the information about version, every line in the following represents a operation and its latency.</p>
</div>
<div class="section" id="version">
<h2>Version<a class="headerlink" href="#version" title="Permalink to this headline"></a></h2>
<p>The information about version split by comma in the english format, and the detail is hardware, inference engine and timestamp.</p>
<ul class="simple">
<li>** hardware: ** Used to mark the environment of hardware, including type of architecture, version and so on.</li>
<li>** inference engine: ** Used to mark inference engine, including the name of inference engine, version, optimize options and so on.</li>
<li>** timestamp: ** Used to mark the time of this table created.</li>
</ul>
</div>
<div class="section" id="operation">
<h2>Operation<a class="headerlink" href="#operation" title="Permalink to this headline"></a></h2>
<p>The information about operation split by comma in the english format, the information about operation and latency split by tabs.</p>
<div class="section" id="conv2d">
<h3>conv2d<a class="headerlink" href="#conv2d" title="Permalink to this headline"></a></h3>
<p><strong>format</strong></p>
<div class="highlight-text"><div class="highlight"><pre><span></span>op_type,flag_bias,flag_relu,n_in,c_in,h_in,w_in,c_out,groups,kernel,padding,stride,dilation\tlatency
</pre></div>
</div>
<p><strong>introduce</strong></p>
<ul class="simple">
<li><strong>op_type(str)</strong> - The type of this op.</li>
<li><strong>flag_bias (int)</strong> - Whether has bias or not(0: donot has bias, 1: has bias).</li>
<li><strong>flag_relu (int)</strong> - Whether has relu or not(0: donot has relu, 1: has relu).</li>
<li><strong>n_in (int)</strong> - The batch size of input.</li>
<li><strong>c_in (int)</strong> - The number of channel about input.</li>
<li><strong>h_in (int)</strong> - The height of input feature map.</li>
<li><strong>w_in (int)</strong> - The width of input feature map.</li>
<li><strong>c_out (int)</strong> - The number of channel about output.</li>
<li><strong>groups (int)</strong> - The group of conv2d.</li>
<li><strong>kernel (int)</strong> - The size of kernel.</li>
<li><strong>padding (int)</strong> - The size of padding.</li>
<li><strong>stride (int)</strong> - The size of stride.</li>
<li><strong>dilation (int)</strong> - The size of dilation.</li>
<li><strong>latency (float)</strong> - The latency of this op.</li>
</ul>
</div>
<div class="section" id="activaiton">
<h3>activaiton<a class="headerlink" href="#activaiton" title="Permalink to this headline"></a></h3>
<p><strong>format</strong></p>
<div class="highlight-text"><div class="highlight"><pre><span></span>op_type,n_in,c_in,h_in,w_in\tlatency
</pre></div>
</div>
<p><strong>introduce</strong></p>
<ul class="simple">
<li><strong>op_type(str)</strong> - The type of this op.</li>
<li><strong>n_in (int)</strong> - The batch size of input.</li>
<li><strong>c_in (int)</strong> - The number of channel about input.</li>
<li><strong>h_in (int)</strong> - The height of input feature map.</li>
<li><strong>w_in (int)</strong> - The width of input feature map.</li>
<li><strong>latency (float)</strong> - The latency of this op.</li>
</ul>
</div>
<div class="section" id="batch-norm">
<h3>batch_norm<a class="headerlink" href="#batch-norm" title="Permalink to this headline"></a></h3>
<p><strong>format</strong></p>
<div class="highlight-text"><div class="highlight"><pre><span></span>op_type,active_type,n_in,c_in,h_in,w_in\tlatency
</pre></div>
</div>
<p><strong>introduce</strong></p>
<ul class="simple">
<li><strong>op_type(str)</strong> - The type of this op.</li>
<li><strong>active_type (string|None)</strong> - The type of activation function, including relu, prelu, sigmoid, relu6, tanh.</li>
<li><strong>n_in (int)</strong> - The batch size of input.</li>
<li><strong>c_in (int)</strong> - The number of channel about input.</li>
<li><strong>h_in (int)</strong> - The height of input feature map.</li>
<li><strong>w_in (int)</strong> - The width of input feature map.</li>
<li><strong>latency (float)</strong> - The latency of this op.</li>
</ul>
</div>
<div class="section" id="eltwise">
<h3>eltwise<a class="headerlink" href="#eltwise" title="Permalink to this headline"></a></h3>
<p><strong>format</strong></p>
<div class="highlight-text"><div class="highlight"><pre><span></span>op_type,n_in,c_in,h_in,w_in\tlatency
</pre></div>
</div>
<p><strong>introduce</strong></p>
<ul class="simple">
<li><strong>op_type(str)</strong> - The type of this op.</li>
<li><strong>n_in (int)</strong> - The batch size of input.</li>
<li><strong>c_in (int)</strong> - The number of channel about input.</li>
<li><strong>h_in (int)</strong> - The height of input feature map.</li>
<li><strong>w_in (int)</strong> - The width of input feature map.</li>
<li><strong>latency (float)</strong> - The latency of this op.</li>
</ul>
</div>
<div class="section" id="pooling">
<h3>pooling<a class="headerlink" href="#pooling" title="Permalink to this headline"></a></h3>
<p><strong>format</strong></p>
<div class="highlight-text"><div class="highlight"><pre><span></span>op_type,flag_global_pooling,n_in,c_in,h_in,w_in,kernel,padding,stride,ceil_mode,pool_type\tlatency
</pre></div>
</div>
<p><strong>introduce</strong></p>
<ul class="simple">
<li><strong>op_type(str)</strong> - The type of this op.</li>
<li><strong>flag_global_pooling (int)</strong> - Whether is global pooling or not(0: is not global, 1: is global pooling).</li>
<li><strong>n_in (int)</strong> - The batch size of input.</li>
<li><strong>c_in (int)</strong> - The number of channel about input.</li>
<li><strong>h_in (int)</strong> - The height of input feature map.</li>
<li><strong>w_in (int)</strong> - The width of input feature map.</li>
<li><strong>kernel (int)</strong> - The size of kernel.</li>
<li><strong>padding (int)</strong> - The size of padding.</li>
<li><strong>stride (int)</strong> - The size of stride.</li>
<li><strong>ceil_mode (int)</strong> - Whether to compute height and width by using ceil function(0: use floor function, 1: use ceil function).</li>
<li><strong>pool_type (int)</strong> - The type of pooling(1: max pooling 2: average pooling including padding 3: average pooling excluding padding).</li>
<li><strong>latency (float)</strong> - The latency of this op.</li>
</ul>
</div>
<div class="section" id="softmax">
<h3>softmax<a class="headerlink" href="#softmax" title="Permalink to this headline"></a></h3>
<p><strong>format</strong></p>
<div class="highlight-text"><div class="highlight"><pre><span></span>op_type,axis,n_in,c_in,h_in,w_in\tlatency
</pre></div>
</div>
<p><strong>introduce</strong></p>
<ul class="simple">
<li><strong>op_type(str)</strong> - The type of this op.</li>
<li><strong>axis (int)</strong> - The index to compute softmax, index in the range of [-1, rank-1], <code class="docutils literal"><span class="pre">rank</span></code> is the rank of input.</li>
<li><strong>n_in (int)</strong> - The batch size of input.</li>
<li><strong>c_in (int)</strong> - The number of channel about input.</li>
<li><strong>h_in (int)</strong> - The height of input feature map.</li>
<li><strong>w_in (int)</strong> - The width of input feature map.</li>
<li><strong>latency (float)</strong> - The latency of this op.</li>
</ul>
</div>
</div>
</div>
</div>
</div>
<footer>
<div class="rst-footer-buttons" role="navigation" aria-label="footer navigation">
<a href="../model_zoo_en.html" class="btn btn-neutral float-right" title="Model Zoo" accesskey="n">Next <span class="fa fa-arrow-circle-right"></span></a>
<a href="search_space_en.html" class="btn btn-neutral" title="search space" accesskey="p"><span class="fa fa-arrow-circle-left"></span> Previous</a>
</div>
<hr/>
<div role="contentinfo">
<p>
&copy; Copyright 2020, paddleslim.
</p>
</div>
Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/snide/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>.
</footer>
</div>
</div>
</section>
</div>
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT:'../',
VERSION:'1.0',
COLLAPSE_INDEX:false,
FILE_SUFFIX:'.html',
HAS_SOURCE: true
};
</script>
<script type="text/javascript" src="../_static/jquery.js"></script>
<script type="text/javascript" src="../_static/underscore.js"></script>
<script type="text/javascript" src="../_static/doctools.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
<script type="text/javascript" src="../_static/js/theme.js"></script>
<script type="text/javascript">
jQuery(function () {
SphinxRtdTheme.StickyNav.enable();
});
</script>
</body>
</html>
\ No newline at end of file
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>欢迎使用PaddleSlim &mdash; PaddleSlim 1.0 文档</title> <title>首页 &mdash; PaddleSlim 1.0 文档</title>
...@@ -81,7 +81,7 @@ ...@@ -81,7 +81,7 @@
<ul> <ul>
<li class="toctree-l1"><a class="reference internal" href="index_en.html">English Documents</a></li> <li class="toctree-l1"><a class="reference internal" href="index_en.html">English Documents</a></li>
<li class="toctree-l1"><a class="reference internal" href="intro.html">PaddleSlim简介</a></li> <li class="toctree-l1"><a class="reference internal" href="intro.html">介绍</a></li>
<li class="toctree-l1"><a class="reference internal" href="install.html">安装</a></li> <li class="toctree-l1"><a class="reference internal" href="install.html">安装</a></li>
<li class="toctree-l1"><a class="reference internal" href="quick_start/index.html">快速开始</a></li> <li class="toctree-l1"><a class="reference internal" href="quick_start/index.html">快速开始</a></li>
<li class="toctree-l1"><a class="reference internal" href="tutorials/index.html">进阶教程</a></li> <li class="toctree-l1"><a class="reference internal" href="tutorials/index.html">进阶教程</a></li>
...@@ -118,7 +118,7 @@ ...@@ -118,7 +118,7 @@
<ul class="wy-breadcrumbs"> <ul class="wy-breadcrumbs">
<li><a href="#">Docs</a> &raquo;</li> <li><a href="#">Docs</a> &raquo;</li>
<li>欢迎使用PaddleSlim</li> <li>首页</li>
<li class="wy-breadcrumbs-aside"> <li class="wy-breadcrumbs-aside">
...@@ -132,12 +132,12 @@ ...@@ -132,12 +132,12 @@
<div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article"> <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
<div itemprop="articleBody"> <div itemprop="articleBody">
<div class="section" id="paddleslim"> <div class="section" id="id1">
<h1>欢迎使用PaddleSlim<a class="headerlink" href="#paddleslim" title="永久链接至标题"></a></h1> <h1>首页<a class="headerlink" href="#id1" title="永久链接至标题"></a></h1>
<div class="toctree-wrapper compound"> <div class="toctree-wrapper compound">
<ul> <ul>
<li class="toctree-l1"><a class="reference internal" href="index_en.html">English Documents</a></li> <li class="toctree-l1"><a class="reference internal" href="index_en.html">English Documents</a></li>
<li class="toctree-l1"><a class="reference internal" href="intro.html">PaddleSlim简介</a></li> <li class="toctree-l1"><a class="reference internal" href="intro.html">介绍</a></li>
<li class="toctree-l1"><a class="reference internal" href="install.html">安装</a></li> <li class="toctree-l1"><a class="reference internal" href="install.html">安装</a></li>
<li class="toctree-l1"><a class="reference internal" href="quick_start/index.html">快速开始</a></li> <li class="toctree-l1"><a class="reference internal" href="quick_start/index.html">快速开始</a></li>
<li class="toctree-l1"><a class="reference internal" href="tutorials/index.html">进阶教程</a></li> <li class="toctree-l1"><a class="reference internal" href="tutorials/index.html">进阶教程</a></li>
...@@ -146,6 +146,168 @@ ...@@ -146,6 +146,168 @@
<li class="toctree-l1"><a class="reference internal" href="algo/algo.html">算法原理</a></li> <li class="toctree-l1"><a class="reference internal" href="algo/algo.html">算法原理</a></li>
</ul> </ul>
</div> </div>
</div>
<div class="section" id="id2">
<h1>介绍<a class="headerlink" href="#id2" title="永久链接至标题"></a></h1>
<p>PaddleSlim是一个模型压缩工具库,包含模型剪裁、定点量化、知识蒸馏、超参搜索和模型结构搜索等一系列模型压缩策略。</p>
<p>对于业务用户,PaddleSlim提供完整的模型压缩解决方案,可用于图像分类、检测、分割等各种类型的视觉场景。
同时也在持续探索NLP领域模型的压缩方案。另外,PaddleSlim提供且在不断完善各种压缩策略在经典开源任务的benchmark,
以便业务用户参考。</p>
<p>对于模型压缩算法研究者或开发者,PaddleSlim提供各种压缩策略的底层辅助接口,方便用户复现、调研和使用最新论文方法。
PaddleSlim会从底层能力、技术咨询合作和业务场景等角度支持开发者进行模型压缩策略相关的创新工作。</p>
<div class="section" id="id3">
<h2>功能<a class="headerlink" href="#id3" title="永久链接至标题"></a></h2>
<ul class="simple">
<li>模型剪裁<ul>
<li>卷积通道均匀剪裁</li>
<li>基于敏感度的卷积通道剪裁</li>
<li>基于进化算法的自动剪裁</li>
</ul>
</li>
<li>定点量化<ul>
<li>在线量化训练(training aware)</li>
<li>离线量化(post training)</li>
</ul>
</li>
<li>知识蒸馏<ul>
<li>支持单进程知识蒸馏</li>
<li>支持多进程分布式知识蒸馏</li>
</ul>
</li>
<li>神经网络结构自动搜索(NAS)<ul>
<li>支持基于进化算法的轻量神经网络结构自动搜索</li>
<li>支持One-Shot网络结构自动搜索</li>
<li>支持 FLOPS / 硬件延时约束</li>
<li>支持多平台模型延时评估</li>
<li>支持用户自定义搜索算法和搜索空间</li>
</ul>
</li>
</ul>
</div>
<div class="section" id="id4">
<h2>部分压缩策略效果<a class="headerlink" href="#id4" title="永久链接至标题"></a></h2>
<div class="section" id="id5">
<h3>分类模型<a class="headerlink" href="#id5" title="永久链接至标题"></a></h3>
<p>数据: ImageNet2012; 模型: MobileNetV1;</p>
<table border="1" class="docutils">
<colgroup>
<col width="33%" />
<col width="33%" />
<col width="33%" />
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head">压缩策略</th>
<th class="head">精度收益(baseline: 70.91%)</th>
<th class="head">模型大小(baseline: 17.0M)</th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td>知识蒸馏(ResNet50)</td>
<td><strong>+1.06%</strong></td>
<td>&#160;</td>
</tr>
<tr class="row-odd"><td>知识蒸馏(ResNet50) + int8量化训练</td>
<td><strong>+1.10%</strong></td>
<td><strong>-71.76%</strong></td>
</tr>
<tr class="row-even"><td>剪裁(FLOPs-50%) + int8量化训练</td>
<td><strong>-1.71%</strong></td>
<td><strong>-86.47%</strong></td>
</tr>
</tbody>
</table>
</div>
<div class="section" id="id6">
<h3>图像检测模型<a class="headerlink" href="#id6" title="永久链接至标题"></a></h3>
<div class="section" id="pascal-voc-mobilenet-v1-yolov3">
<h4>数据:Pascal VOC;模型:MobileNet-V1-YOLOv3<a class="headerlink" href="#pascal-voc-mobilenet-v1-yolov3" title="永久链接至标题"></a></h4>
<table border="1" class="docutils">
<colgroup>
<col width="33%" />
<col width="33%" />
<col width="33%" />
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head">压缩方法</th>
<th class="head">mAP(baseline: 76.2%)</th>
<th class="head">模型大小(baseline: 94MB)</th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td>知识蒸馏(ResNet34-YOLOv3)</td>
<td><strong>+2.8%</strong></td>
<td>&#160;</td>
</tr>
<tr class="row-odd"><td>剪裁 FLOPs -52.88%</td>
<td><strong>+1.4%</strong></td>
<td><strong>-67.76%</strong></td>
</tr>
<tr class="row-even"><td>知识蒸馏(ResNet34-YOLOv3)+剪裁(FLOPs-69.57%)</td>
<td><strong>+2.6%</strong></td>
<td><strong>-67.00%</strong></td>
</tr>
</tbody>
</table>
</div>
<div class="section" id="coco-mobilenet-v1-yolov3">
<h4>数据:COCO;模型:MobileNet-V1-YOLOv3<a class="headerlink" href="#coco-mobilenet-v1-yolov3" title="永久链接至标题"></a></h4>
<table border="1" class="docutils">
<colgroup>
<col width="33%" />
<col width="33%" />
<col width="33%" />
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head">压缩方法</th>
<th class="head">mAP(baseline: 29.3%)</th>
<th class="head">模型大小</th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td>知识蒸馏(ResNet34-YOLOv3)</td>
<td><strong>+2.1%</strong></td>
<td>&#160;</td>
</tr>
<tr class="row-odd"><td>知识蒸馏(ResNet34-YOLOv3)+剪裁(FLOPs-67.56%)</td>
<td><strong>-0.3%</strong></td>
<td><strong>-66.90%</strong></td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="section" id="id7">
<h3>搜索<a class="headerlink" href="#id7" title="永久链接至标题"></a></h3>
<p>数据:ImageNet2012; 模型:MobileNetV2</p>
<table border="1" class="docutils">
<colgroup>
<col width="33%" />
<col width="33%" />
<col width="33%" />
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head">硬件环境</th>
<th class="head">推理耗时</th>
<th class="head">Top1准确率(baseline:71.90%)</th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td>RK3288</td>
<td><strong>-23%</strong></td>
<td>+0.07%</td>
</tr>
<tr class="row-odd"><td>Android cellphone</td>
<td><strong>-20%</strong></td>
<td>+0.16%</td>
</tr>
<tr class="row-even"><td>iPhone 6s</td>
<td><strong>-17%</strong></td>
<td>+0.32%</td>
</tr>
</tbody>
</table>
</div>
</div>
</div> </div>
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Welcome to use PaddleSlim. &mdash; PaddleSlim 1.0 documentation</title> <title>Index &mdash; PaddleSlim 1.0 documentation</title>
...@@ -117,7 +117,7 @@ ...@@ -117,7 +117,7 @@
<ul class="wy-breadcrumbs"> <ul class="wy-breadcrumbs">
<li><a href="#">Docs</a> &raquo;</li> <li><a href="#">Docs</a> &raquo;</li>
<li>Welcome to use PaddleSlim.</li> <li>Index</li>
<li class="wy-breadcrumbs-aside"> <li class="wy-breadcrumbs-aside">
...@@ -131,8 +131,8 @@ ...@@ -131,8 +131,8 @@
<div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article"> <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
<div itemprop="articleBody"> <div itemprop="articleBody">
<div class="section" id="welcome-to-use-paddleslim"> <div class="section" id="index">
<h1>Welcome to use PaddleSlim.<a class="headerlink" href="#welcome-to-use-paddleslim" title="Permalink to this headline"></a></h1> <h1>Index<a class="headerlink" href="#index" title="Permalink to this headline"></a></h1>
<div class="toctree-wrapper compound"> <div class="toctree-wrapper compound">
<ul> <ul>
<li class="toctree-l1"><a class="reference internal" href="index.html">中文文档</a></li> <li class="toctree-l1"><a class="reference internal" href="index.html">中文文档</a></li>
...@@ -144,6 +144,187 @@ ...@@ -144,6 +144,187 @@
<li class="toctree-l1"><a class="reference internal" href="model_zoo_en.html">Model Zoo</a></li> <li class="toctree-l1"><a class="reference internal" href="model_zoo_en.html">Model Zoo</a></li>
</ul> </ul>
</div> </div>
</div>
<div class="section" id="introduction">
<h1>Introduction<a class="headerlink" href="#introduction" title="Permalink to this headline"></a></h1>
<p>PaddleSlim is a toolkit for model compression. It contains a collection of compression strategies, such as pruning, fixed point quantization, knowledge distillation, hyperparameter searching and neural architecture search.</p>
<p>PaddleSlim provides solutions of compression on computer vision models, such as image classification, object detection and semantic segmentation. Meanwhile, PaddleSlim Keeps exploring advanced compression strategies for language model. Furthermore, benckmark of compression strategies on some open tasks is available for your reference.</p>
<p>PaddleSlim also provides auxiliary and primitive API for developer and researcher to survey, implement and apply the method in latest papers. PaddleSlim will support developer in ability of framework and technology consulting.</p>
<div class="section" id="features">
<h2>Features<a class="headerlink" href="#features" title="Permalink to this headline"></a></h2>
<div class="section" id="pruning">
<h3>Pruning<a class="headerlink" href="#pruning" title="Permalink to this headline"></a></h3>
<ul class="simple">
<li>Uniform pruning of convolution</li>
<li>Sensitivity-based prunning</li>
<li>Automated pruning based evolution search strategy</li>
<li>Support pruning of various deep architectures such as VGG, ResNet, and MobileNet.</li>
<li>Support self-defined range of pruning, i.e., layers to be pruned.</li>
</ul>
</div>
<div class="section" id="fixed-point-quantization">
<h3>Fixed Point Quantization<a class="headerlink" href="#fixed-point-quantization" title="Permalink to this headline"></a></h3>
<ul class="simple">
<li><strong>Training aware</strong><ul>
<li>Dynamic strategy: During inference, we quantize models with hyperparameters dynamically estimated from small batches of samples.</li>
<li>Static strategy: During inference, we quantize models with the same hyperparameters estimated from training data.</li>
<li>Support layer-wise and channel-wise quantization.</li>
</ul>
</li>
<li><strong>Post training</strong></li>
</ul>
</div>
<div class="section" id="knowledge-distillation">
<h3>Knowledge Distillation<a class="headerlink" href="#knowledge-distillation" title="Permalink to this headline"></a></h3>
<ul class="simple">
<li><strong>Naive knowledge distillation:</strong> transfers dark knowledge by merging the teacher and student model into the same Program</li>
<li><strong>Paddle large-scale scalable knowledge distillation framework Pantheon:</strong> a universal solution for knowledge distillation, more flexible than the naive knowledge distillation, and easier to scale to the large-scale applications.<ul>
<li>Decouple the teacher and student models &#8212; they run in different processes in the same or different nodes, and transfer knowledge via TCP/IP ports or local files;</li>
<li>Friendly to assemble multiple teacher models and each of them can work in either online or offline mode independently;</li>
<li>Merge knowledge from different teachers and make batch data for the student model automatically;</li>
<li>Support the large-scale knowledge prediction of teacher models on multiple devices.</li>
</ul>
</li>
</ul>
</div>
<div class="section" id="neural-architecture-search">
<h3>Neural Architecture Search<a class="headerlink" href="#neural-architecture-search" title="Permalink to this headline"></a></h3>
<ul class="simple">
<li>Neural architecture search based on evolution strategy.</li>
<li>Support distributed search.</li>
<li>One-Shot neural architecture search.</li>
<li>Support FLOPs and latency constrained search.</li>
<li>Support the latency estimation on different hardware and platforms.</li>
</ul>
</div>
</div>
<div class="section" id="performance">
<h2>Performance<a class="headerlink" href="#performance" title="Permalink to this headline"></a></h2>
<div class="section" id="image-classification">
<h3>Image Classification<a class="headerlink" href="#image-classification" title="Permalink to this headline"></a></h3>
<p>Dataset: ImageNet2012; Model: MobileNetV1;</p>
<table border="1" class="docutils">
<colgroup>
<col width="33%" />
<col width="33%" />
<col width="33%" />
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head">Method</th>
<th class="head">Accuracy(baseline: 70.91%)</th>
<th class="head">Model Size(baseline: 17.0M)</th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td>Knowledge Distillation(ResNet50)</td>
<td><strong>+1.06%</strong></td>
<td>&#160;</td>
</tr>
<tr class="row-odd"><td>Knowledge Distillation(ResNet50) + int8 quantization</td>
<td><strong>+1.10%</strong></td>
<td><strong>-71.76%</strong></td>
</tr>
<tr class="row-even"><td>Pruning(FLOPs-50%) + int8 quantization</td>
<td><strong>-1.71%</strong></td>
<td><strong>-86.47%</strong></td>
</tr>
</tbody>
</table>
</div>
<div class="section" id="object-detection">
<h3>Object Detection<a class="headerlink" href="#object-detection" title="Permalink to this headline"></a></h3>
<div class="section" id="dataset-pascal-voc-model-mobilenet-v1-yolov3">
<h4>Dataset: Pascal VOC; Model: MobileNet-V1-YOLOv3<a class="headerlink" href="#dataset-pascal-voc-model-mobilenet-v1-yolov3" title="Permalink to this headline"></a></h4>
<table border="1" class="docutils">
<colgroup>
<col width="33%" />
<col width="33%" />
<col width="33%" />
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head">Method</th>
<th class="head">mAP(baseline: 76.2%)</th>
<th class="head">Model Size(baseline: 94MB)</th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td>Knowledge Distillation(ResNet34-YOLOv3)</td>
<td><strong>+2.8%</strong></td>
<td>&#160;</td>
</tr>
<tr class="row-odd"><td>Pruning(FLOPs -52.88%)</td>
<td><strong>+1.4%</strong></td>
<td><strong>-67.76%</strong></td>
</tr>
<tr class="row-even"><td>Knowledge DistillationResNet34-YOLOv3)+Pruning(FLOPs-69.57%)</td>
<td><strong>+2.6%</strong></td>
<td><strong>-67.00%</strong></td>
</tr>
</tbody>
</table>
</div>
<div class="section" id="dataset-coco-model-mobilenet-v1-yolov3">
<h4>Dataset: COCO; Model: MobileNet-V1-YOLOv3<a class="headerlink" href="#dataset-coco-model-mobilenet-v1-yolov3" title="Permalink to this headline"></a></h4>
<table border="1" class="docutils">
<colgroup>
<col width="33%" />
<col width="33%" />
<col width="33%" />
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head">Method</th>
<th class="head">mAP(baseline: 29.3%)</th>
<th class="head">Model Size</th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td>Knowledge Distillation(ResNet34-YOLOv3)</td>
<td><strong>+2.1%</strong></td>
<td><ul class="first last simple">
<li></li>
</ul>
</td>
</tr>
<tr class="row-odd"><td>Knowledge Distillation(ResNet34-YOLOv3)+Pruning(FLOPs-67.56%)</td>
<td><strong>-0.3%</strong></td>
<td><strong>-66.90%</strong></td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="section" id="nas">
<h3>NAS<a class="headerlink" href="#nas" title="Permalink to this headline"></a></h3>
<p>Dataset: ImageNet2012; Model: MobileNetV2</p>
<table border="1" class="docutils">
<colgroup>
<col width="33%" />
<col width="33%" />
<col width="33%" />
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head">Device</th>
<th class="head">Infer time cost</th>
<th class="head">Top1 accuracy(baseline:71.90%)</th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td>RK3288</td>
<td><strong>-23%</strong></td>
<td>+0.07%</td>
</tr>
<tr class="row-odd"><td>Android cellphone</td>
<td><strong>-20%</strong></td>
<td>+0.16%</td>
</tr>
<tr class="row-even"><td>iPhone 6s</td>
<td><strong>-17%</strong></td>
<td>+0.32%</td>
</tr>
</tbody>
</table>
</div>
</div>
</div> </div>
......
...@@ -35,7 +35,7 @@ ...@@ -35,7 +35,7 @@
<link rel="search" title="搜索" href="search.html"/> <link rel="search" title="搜索" href="search.html"/>
<link rel="top" title="PaddleSlim 1.0 文档" href="index.html"/> <link rel="top" title="PaddleSlim 1.0 文档" href="index.html"/>
<link rel="next" title="快速开始" href="quick_start/index.html"/> <link rel="next" title="快速开始" href="quick_start/index.html"/>
<link rel="prev" title="PaddleSlim简介" href="intro.html"/> <link rel="prev" title="介绍" href="intro.html"/>
<script src="_static/js/modernizr.min.js"></script> <script src="_static/js/modernizr.min.js"></script>
...@@ -82,7 +82,7 @@ ...@@ -82,7 +82,7 @@
<ul class="current"> <ul class="current">
<li class="toctree-l1"><a class="reference internal" href="index_en.html">English Documents</a></li> <li class="toctree-l1"><a class="reference internal" href="index_en.html">English Documents</a></li>
<li class="toctree-l1"><a class="reference internal" href="intro.html">PaddleSlim简介</a></li> <li class="toctree-l1"><a class="reference internal" href="intro.html">介绍</a></li>
<li class="toctree-l1 current"><a class="current reference internal" href="#">安装</a></li> <li class="toctree-l1 current"><a class="current reference internal" href="#">安装</a></li>
<li class="toctree-l1"><a class="reference internal" href="quick_start/index.html">快速开始</a></li> <li class="toctree-l1"><a class="reference internal" href="quick_start/index.html">快速开始</a></li>
<li class="toctree-l1"><a class="reference internal" href="tutorials/index.html">进阶教程</a></li> <li class="toctree-l1"><a class="reference internal" href="tutorials/index.html">进阶教程</a></li>
...@@ -166,7 +166,7 @@ python setup.py install ...@@ -166,7 +166,7 @@ python setup.py install
<a href="quick_start/index.html" class="btn btn-neutral float-right" title="快速开始" accesskey="n">Next <span class="fa fa-arrow-circle-right"></span></a> <a href="quick_start/index.html" class="btn btn-neutral float-right" title="快速开始" accesskey="n">Next <span class="fa fa-arrow-circle-right"></span></a>
<a href="intro.html" class="btn btn-neutral" title="PaddleSlim简介" accesskey="p"><span class="fa fa-arrow-circle-left"></span> Previous</a> <a href="intro.html" class="btn btn-neutral" title="介绍" accesskey="p"><span class="fa fa-arrow-circle-left"></span> Previous</a>
</div> </div>
......
...@@ -134,25 +134,25 @@ ...@@ -134,25 +134,25 @@
<div class="section" id="install"> <div class="section" id="install">
<h1>Install<a class="headerlink" href="#install" title="Permalink to this headline"></a></h1> <h1>Install<a class="headerlink" href="#install" title="Permalink to this headline"></a></h1>
<p>安装PaddleSlim前,请确认已正确安装Paddle1.6版本或更新版本。Paddle安装请参考:<a class="reference external" href="https://www.paddlepaddle.org.cn/install/quick">Paddle安装教程</a></p> <p>Please ensure you have installed PaddlePaddle1.7+. <a class="reference external" href="https://www.paddlepaddle.org.cn/install/quick">How to install PaddlePaddle</a></p>
<ul class="simple"> <ul class="simple">
<li>安装develop版本</li> <li>Install by pip</li>
</ul> </ul>
<div class="highlight-bash"><div class="highlight"><pre><span></span>git clone https://github.com/PaddlePaddle/PaddleSlim.git <div class="highlight-bash"><div class="highlight"><pre><span></span>pip install paddleslim -i https://pypi.org/simple
<span class="nb">cd</span> PaddleSlim
python setup.py install
</pre></div> </pre></div>
</div> </div>
<ul class="simple"> <ul class="simple">
<li>安装官方发布的最新版本</li> <li>Install from source</li>
</ul> </ul>
<div class="highlight-bash"><div class="highlight"><pre><span></span>pip install paddleslim -i https://pypi.org/simple <div class="highlight-bash"><div class="highlight"><pre><span></span>git clone https://github.com/PaddlePaddle/PaddleSlim.git
<span class="nb">cd</span> PaddleSlim
python setup.py install
</pre></div> </pre></div>
</div> </div>
<ul class="simple"> <ul class="simple">
<li>安装历史版本</li> <li>History packages</li>
</ul> </ul>
<p>请点击<a class="reference external" href="https://pypi.org/project/paddleslim/#history">pypi.org</a>查看可安装历史版本。</p> <p>History packages is available in <a class="reference external" href="https://pypi.org/project/paddleslim/#history">pypi.org</a>.</p>
</div> </div>
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>PaddleSlim简介 &mdash; PaddleSlim 1.0 文档</title> <title>介绍 &mdash; PaddleSlim 1.0 文档</title>
...@@ -82,8 +82,18 @@ ...@@ -82,8 +82,18 @@
<ul class="current"> <ul class="current">
<li class="toctree-l1"><a class="reference internal" href="index_en.html">English Documents</a></li> <li class="toctree-l1"><a class="reference internal" href="index_en.html">English Documents</a></li>
<li class="toctree-l1 current"><a class="current reference internal" href="#">PaddleSlim简介</a><ul> <li class="toctree-l1 current"><a class="current reference internal" href="#">介绍</a><ul>
<li class="toctree-l2"><a class="reference internal" href="#id1">功能</a></li> <li class="toctree-l2"><a class="reference internal" href="#id2">功能</a></li>
<li class="toctree-l2"><a class="reference internal" href="#id3">部分压缩策略效果</a><ul>
<li class="toctree-l3"><a class="reference internal" href="#id4">分类模型</a></li>
<li class="toctree-l3"><a class="reference internal" href="#id5">图像检测模型</a><ul>
<li class="toctree-l4"><a class="reference internal" href="#pascal-voc-mobilenet-v1-yolov3">数据:Pascal VOC;模型:MobileNet-V1-YOLOv3</a></li>
<li class="toctree-l4"><a class="reference internal" href="#coco-mobilenet-v1-yolov3">数据:COCO;模型:MobileNet-V1-YOLOv3</a></li>
</ul>
</li>
<li class="toctree-l3"><a class="reference internal" href="#id6">搜索</a></li>
</ul>
</li>
</ul> </ul>
</li> </li>
<li class="toctree-l1"><a class="reference internal" href="install.html">安装</a></li> <li class="toctree-l1"><a class="reference internal" href="install.html">安装</a></li>
...@@ -122,7 +132,7 @@ ...@@ -122,7 +132,7 @@
<ul class="wy-breadcrumbs"> <ul class="wy-breadcrumbs">
<li><a href="index.html">Docs</a> &raquo;</li> <li><a href="index.html">Docs</a> &raquo;</li>
<li>PaddleSlim简介</li> <li>介绍</li>
<li class="wy-breadcrumbs-aside"> <li class="wy-breadcrumbs-aside">
...@@ -136,22 +146,26 @@ ...@@ -136,22 +146,26 @@
<div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article"> <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
<div itemprop="articleBody"> <div itemprop="articleBody">
<div class="section" id="paddleslim"> <div class="section" id="id1">
<h1>PaddleSlim简介<a class="headerlink" href="#paddleslim" title="永久链接至标题"></a></h1> <h1>介绍<a class="headerlink" href="#id1" title="永久链接至标题"></a></h1>
<p>PaddleSlim是PaddlePaddle框架的一个子模块,主要用于压缩图像领域模型。在PaddleSlim中,不仅实现了目前主流的网络剪枝、量化、蒸馏三种压缩策略,还实现了超参数搜索和小模型网络结构搜索功能。在后续版本中,会添加更多的压缩策略,以及完善对NLP领域模型的支持。</p> <p>PaddleSlim是一个模型压缩工具库,包含模型剪裁、定点量化、知识蒸馏、超参搜索和模型结构搜索等一系列模型压缩策略。</p>
<div class="section" id="id1"> <p>对于业务用户,PaddleSlim提供完整的模型压缩解决方案,可用于图像分类、检测、分割等各种类型的视觉场景。
<h2>功能<a class="headerlink" href="#id1" title="永久链接至标题"></a></h2> 同时也在持续探索NLP领域模型的压缩方案。另外,PaddleSlim提供且在不断完善各种压缩策略在经典开源任务的benchmark,
以便业务用户参考。</p>
<p>对于模型压缩算法研究者或开发者,PaddleSlim提供各种压缩策略的底层辅助接口,方便用户复现、调研和使用最新论文方法。
PaddleSlim会从底层能力、技术咨询合作和业务场景等角度支持开发者进行模型压缩策略相关的创新工作。</p>
<div class="section" id="id2">
<h2>功能<a class="headerlink" href="#id2" title="永久链接至标题"></a></h2>
<ul class="simple"> <ul class="simple">
<li>模型剪裁<ul> <li>模型剪裁<ul>
<li>支持通道均匀模型剪裁(uniform pruning)</li> <li>卷积通道均匀剪裁</li>
<li>基于敏感度的模型剪裁</li> <li>基于敏感度的卷积通道剪裁</li>
<li>基于进化算法的自动模型剪裁三种方式</li> <li>基于进化算法的自动剪裁</li>
</ul> </ul>
</li> </li>
<li>量化训练<ul> <li>定点量化<ul>
<li>在线量化训练(training aware)</li> <li>在线量化训练(training aware)</li>
<li>离线量化(post training)</li> <li>离线量化(post training)</li>
<li>支持对权重全局量化和Channel-Wise量化</li>
</ul> </ul>
</li> </li>
<li>知识蒸馏<ul> <li>知识蒸馏<ul>
...@@ -160,14 +174,130 @@ ...@@ -160,14 +174,130 @@
</ul> </ul>
</li> </li>
<li>神经网络结构自动搜索(NAS)<ul> <li>神经网络结构自动搜索(NAS)<ul>
<li>支持One-Shot网络结构自动搜索(Ont-Shot-NAS)</li> <li>支持基于进化算法的轻量神经网络结构自动搜索</li>
<li>支持基于进化算法的轻量神经网络结构自动搜索(Light-NAS)</li> <li>支持One-Shot网络结构自动搜索</li>
<li>支持 FLOPS / 硬件延时约束</li> <li>支持 FLOPS / 硬件延时约束</li>
<li>支持多平台模型延时评估</li> <li>支持多平台模型延时评估</li>
<li>支持用户自定义搜索算法和搜索空间</li>
</ul> </ul>
</li> </li>
</ul> </ul>
</div> </div>
<div class="section" id="id3">
<h2>部分压缩策略效果<a class="headerlink" href="#id3" title="永久链接至标题"></a></h2>
<div class="section" id="id4">
<h3>分类模型<a class="headerlink" href="#id4" title="永久链接至标题"></a></h3>
<p>数据: ImageNet2012; 模型: MobileNetV1;</p>
<table border="1" class="docutils">
<thead>
<tr>
<th align="center">压缩策略</th>
<th align="center">精度收益(baseline: 70.91%)</th>
<th align="center">模型大小(baseline: 17.0M)</th>
</tr>
</thead>
<tbody>
<tr>
<td align="center">知识蒸馏(ResNet50)</td>
<td align="center"><strong>+1.06%</strong></td>
<td align="center"></td>
</tr>
<tr>
<td align="center">知识蒸馏(ResNet50) + int8量化训练</td>
<td align="center"><strong>+1.10%</strong></td>
<td align="center"><strong>-71.76%</strong></td>
</tr>
<tr>
<td align="center">剪裁(FLOPs-50%) + int8量化训练</td>
<td align="center"><strong>-1.71%</strong></td>
<td align="center"><strong>-86.47%</strong></td>
</tr>
</tbody>
</table></div>
<div class="section" id="id5">
<h3>图像检测模型<a class="headerlink" href="#id5" title="永久链接至标题"></a></h3>
<div class="section" id="pascal-voc-mobilenet-v1-yolov3">
<h4>数据:Pascal VOC;模型:MobileNet-V1-YOLOv3<a class="headerlink" href="#pascal-voc-mobilenet-v1-yolov3" title="永久链接至标题"></a></h4>
<table border="1" class="docutils">
<thead>
<tr>
<th align="center">压缩方法</th>
<th align="center">mAP(baseline: 76.2%)</th>
<th align="center">模型大小(baseline: 94MB)</th>
</tr>
</thead>
<tbody>
<tr>
<td align="center">知识蒸馏(ResNet34-YOLOv3)</td>
<td align="center"><strong>+2.8%</strong></td>
<td align="center"></td>
</tr>
<tr>
<td align="center">剪裁 FLOPs -52.88%</td>
<td align="center"><strong>+1.4%</strong></td>
<td align="center"><strong>-67.76%</strong></td>
</tr>
<tr>
<td align="center">知识蒸馏(ResNet34-YOLOv3)+剪裁(FLOPs-69.57%)</td>
<td align="center"><strong>+2.6%</strong></td>
<td align="center"><strong>-67.00%</strong></td>
</tr>
</tbody>
</table></div>
<div class="section" id="coco-mobilenet-v1-yolov3">
<h4>数据:COCO;模型:MobileNet-V1-YOLOv3<a class="headerlink" href="#coco-mobilenet-v1-yolov3" title="永久链接至标题"></a></h4>
<table border="1" class="docutils">
<thead>
<tr>
<th align="center">压缩方法</th>
<th align="center">mAP(baseline: 29.3%)</th>
<th align="center">模型大小</th>
</tr>
</thead>
<tbody>
<tr>
<td align="center">知识蒸馏(ResNet34-YOLOv3)</td>
<td align="center"><strong>+2.1%</strong></td>
<td align="center"></td>
</tr>
<tr>
<td align="center">知识蒸馏(ResNet34-YOLOv3)+剪裁(FLOPs-67.56%)</td>
<td align="center"><strong>-0.3%</strong></td>
<td align="center"><strong>-66.90%</strong></td>
</tr>
</tbody>
</table></div>
</div>
<div class="section" id="id6">
<h3>搜索<a class="headerlink" href="#id6" title="永久链接至标题"></a></h3>
<p>数据:ImageNet2012; 模型:MobileNetV2</p>
<table border="1" class="docutils">
<thead>
<tr>
<th align="center">硬件环境</th>
<th align="center">推理耗时</th>
<th align="center">Top1准确率(baseline:71.90%)</th>
</tr>
</thead>
<tbody>
<tr>
<td align="center">RK3288</td>
<td align="center"><strong>-23%</strong></td>
<td align="center">+0.07%</td>
</tr>
<tr>
<td align="center">Android cellphone</td>
<td align="center"><strong>-20%</strong></td>
<td align="center">+0.16%</td>
</tr>
<tr>
<td align="center">iPhone 6s</td>
<td align="center"><strong>-17%</strong></td>
<td align="center">+0.32%</td>
</tr>
</tbody>
</table></div>
</div>
</div> </div>
......
...@@ -83,7 +83,23 @@ ...@@ -83,7 +83,23 @@
<ul class="current"> <ul class="current">
<li class="toctree-l1"><a class="reference internal" href="index.html">中文文档</a></li> <li class="toctree-l1"><a class="reference internal" href="index.html">中文文档</a></li>
<li class="toctree-l1 current"><a class="current reference internal" href="#">Introduction</a><ul> <li class="toctree-l1 current"><a class="current reference internal" href="#">Introduction</a><ul>
<li class="toctree-l2"><a class="reference internal" href="#methods">Methods</a></li> <li class="toctree-l2"><a class="reference internal" href="#features">Features</a><ul>
<li class="toctree-l3"><a class="reference internal" href="#pruning">Pruning</a></li>
<li class="toctree-l3"><a class="reference internal" href="#fixed-point-quantization">Fixed Point Quantization</a></li>
<li class="toctree-l3"><a class="reference internal" href="#knowledge-distillation">Knowledge Distillation</a></li>
<li class="toctree-l3"><a class="reference internal" href="#neural-architecture-search">Neural Architecture Search</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="#performance">Performance</a><ul>
<li class="toctree-l3"><a class="reference internal" href="#image-classification">Image Classification</a></li>
<li class="toctree-l3"><a class="reference internal" href="#object-detection">Object Detection</a><ul>
<li class="toctree-l4"><a class="reference internal" href="#dataset-pascal-voc-model-mobilenet-v1-yolov3">Dataset: Pascal VOC; Model: MobileNet-V1-YOLOv3</a></li>
<li class="toctree-l4"><a class="reference internal" href="#dataset-coco-model-mobilenet-v1-yolov3">Dataset: COCO; Model: MobileNet-V1-YOLOv3</a></li>
</ul>
</li>
<li class="toctree-l3"><a class="reference internal" href="#nas">NAS</a></li>
</ul>
</li>
</ul> </ul>
</li> </li>
<li class="toctree-l1"><a class="reference internal" href="install_en.html">Install</a></li> <li class="toctree-l1"><a class="reference internal" href="install_en.html">Install</a></li>
...@@ -137,36 +153,172 @@ ...@@ -137,36 +153,172 @@
<div class="section" id="introduction"> <div class="section" id="introduction">
<h1>Introduction<a class="headerlink" href="#introduction" title="Permalink to this headline"></a></h1> <h1>Introduction<a class="headerlink" href="#introduction" title="Permalink to this headline"></a></h1>
<p>As a submodule of PaddlePaddle framework, PaddleSlim is an open-source library for deep model compression and architecture search. PaddleSlim supports current popular deep compression techniques such as pruning, quantization, and knowledge distillation. Further, it also automates the search of hyperparameters and the design of lightweight deep architectures. In the future, we will develop more practically useful compression techniques for industrial-level applications and transfer these techniques to models in NLP.</p> <p>PaddleSlim is a toolkit for model compression. It contains a collection of compression strategies, such as pruning, fixed point quantization, knowledge distillation, hyperparameter searching and neural architecture search.</p>
<div class="section" id="methods"> <p>PaddleSlim provides solutions of compression on computer vision models, such as image classification, object detection and semantic segmentation. Meanwhile, PaddleSlim Keeps exploring advanced compression strategies for language model. Furthermore, benckmark of compression strategies on some open tasks is available for your reference.</p>
<h2>Methods<a class="headerlink" href="#methods" title="Permalink to this headline"></a></h2> <p>PaddleSlim also provides auxiliary and primitive API for developer and researcher to survey, implement and apply the method in latest papers. PaddleSlim will support developer in ability of framework and technology consulting.</p>
<div class="section" id="features">
<h2>Features<a class="headerlink" href="#features" title="Permalink to this headline"></a></h2>
<div class="section" id="pruning">
<h3>Pruning<a class="headerlink" href="#pruning" title="Permalink to this headline"></a></h3>
<ul class="simple"> <ul class="simple">
<li>Pruning<ul> <li>Uniform pruning of convolution</li>
<li>Uniform pruning</li> <li>Sensitivity-based prunning</li>
<li>Sensitivity-based pruning</li> <li>Automated pruning based evolution search strategy</li>
<li>Automated model pruning</li> <li>Support pruning of various deep architectures such as VGG, ResNet, and MobileNet.</li>
<li>Support self-defined range of pruning, i.e., layers to be pruned.</li>
</ul> </ul>
</li> </div>
<li>Quantization<ul> <div class="section" id="fixed-point-quantization">
<li>Training-aware quantization: Quantize models with hyperparameters dynamically estimated from small batches of samples.</li> <h3>Fixed Point Quantization<a class="headerlink" href="#fixed-point-quantization" title="Permalink to this headline"></a></h3>
<li>Training-aware quantization: Quantize models with the same hyperparameters estimated from training data.</li> <ul class="simple">
<li>Support global quantization of weights and Channel-Wise quantization</li> <li><strong>Training aware</strong><ul>
<li>Dynamic strategy: During inference, we quantize models with hyperparameters dynamically estimated from small batches of samples.</li>
<li>Static strategy: During inference, we quantize models with the same hyperparameters estimated from training data.</li>
<li>Support layer-wise and channel-wise quantization.</li>
</ul> </ul>
</li> </li>
<li>Knowledge Distillation<ul> <li><strong>Post training</strong></li>
<li>Single-process knowledge distillation</li>
<li>Multi-process distributed knowledge distillation</li>
</ul> </ul>
</li> </div>
<li>Network Architecture Search(NAS)<ul> <div class="section" id="knowledge-distillation">
<li>Simulated Annealing (SA)-based lightweight network architecture search method.(Light-NAS)</li> <h3>Knowledge Distillation<a class="headerlink" href="#knowledge-distillation" title="Permalink to this headline"></a></h3>
<li>One-Shot network structure automatic search. (One-Shot-NAS)</li> <ul class="simple">
<li>PaddleSlim supports FLOPs and latency constrained search.</li> <li><strong>Naive knowledge distillation:</strong> transfers dark knowledge by merging the teacher and student model into the same Program</li>
<li>PaddleSlim supports the latency estimation on different hardware and platforms.</li> <li><strong>Paddle large-scale scalable knowledge distillation framework Pantheon:</strong> a universal solution for knowledge distillation, more flexible than the naive knowledge distillation, and easier to scale to the large-scale applications.<ul>
<li>Decouple the teacher and student models &#8212; they run in different processes in the same or different nodes, and transfer knowledge via TCP/IP ports or local files;</li>
<li>Friendly to assemble multiple teacher models and each of them can work in either online or offline mode independently;</li>
<li>Merge knowledge from different teachers and make batch data for the student model automatically;</li>
<li>Support the large-scale knowledge prediction of teacher models on multiple devices.</li>
</ul> </ul>
</li> </li>
</ul> </ul>
</div> </div>
<div class="section" id="neural-architecture-search">
<h3>Neural Architecture Search<a class="headerlink" href="#neural-architecture-search" title="Permalink to this headline"></a></h3>
<ul class="simple">
<li>Neural architecture search based on evolution strategy.</li>
<li>Support distributed search.</li>
<li>One-Shot neural architecture search.</li>
<li>Support FLOPs and latency constrained search.</li>
<li>Support the latency estimation on different hardware and platforms.</li>
</ul>
</div>
</div>
<div class="section" id="performance">
<h2>Performance<a class="headerlink" href="#performance" title="Permalink to this headline"></a></h2>
<div class="section" id="image-classification">
<h3>Image Classification<a class="headerlink" href="#image-classification" title="Permalink to this headline"></a></h3>
<p>Dataset: ImageNet2012; Model: MobileNetV1;</p>
<table border="1" class="docutils">
<thead>
<tr>
<th align="center">Method</th>
<th align="center">Accuracy(baseline: 70.91%)</th>
<th align="center">Model Size(baseline: 17.0M)</th>
</tr>
</thead>
<tbody>
<tr>
<td align="center">Knowledge Distillation(ResNet50)</td>
<td align="center"><strong>+1.06%</strong></td>
<td align="center"></td>
</tr>
<tr>
<td align="center">Knowledge Distillation(ResNet50) + int8 quantization</td>
<td align="center"><strong>+1.10%</strong></td>
<td align="center"><strong>-71.76%</strong></td>
</tr>
<tr>
<td align="center">Pruning(FLOPs-50%) + int8 quantization</td>
<td align="center"><strong>-1.71%</strong></td>
<td align="center"><strong>-86.47%</strong></td>
</tr>
</tbody>
</table></div>
<div class="section" id="object-detection">
<h3>Object Detection<a class="headerlink" href="#object-detection" title="Permalink to this headline"></a></h3>
<div class="section" id="dataset-pascal-voc-model-mobilenet-v1-yolov3">
<h4>Dataset: Pascal VOC; Model: MobileNet-V1-YOLOv3<a class="headerlink" href="#dataset-pascal-voc-model-mobilenet-v1-yolov3" title="Permalink to this headline"></a></h4>
<table border="1" class="docutils">
<thead>
<tr>
<th align="center">Method</th>
<th align="center">mAP(baseline: 76.2%)</th>
<th align="center">Model Size(baseline: 94MB)</th>
</tr>
</thead>
<tbody>
<tr>
<td align="center">Knowledge Distillation(ResNet34-YOLOv3)</td>
<td align="center"><strong>+2.8%</strong></td>
<td align="center"></td>
</tr>
<tr>
<td align="center">Pruning(FLOPs -52.88%)</td>
<td align="center"><strong>+1.4%</strong></td>
<td align="center"><strong>-67.76%</strong></td>
</tr>
<tr>
<td align="center">Knowledge DistillationResNet34-YOLOv3)+Pruning(FLOPs-69.57%)</td>
<td align="center"><strong>+2.6%</strong></td>
<td align="center"><strong>-67.00%</strong></td>
</tr>
</tbody>
</table></div>
<div class="section" id="dataset-coco-model-mobilenet-v1-yolov3">
<h4>Dataset: COCO; Model: MobileNet-V1-YOLOv3<a class="headerlink" href="#dataset-coco-model-mobilenet-v1-yolov3" title="Permalink to this headline"></a></h4>
<table border="1" class="docutils">
<thead>
<tr>
<th align="center">Method</th>
<th align="center">mAP(baseline: 29.3%)</th>
<th align="center">Model Size</th>
</tr>
</thead>
<tbody>
<tr>
<td align="center">Knowledge Distillation(ResNet34-YOLOv3)</td>
<td align="center"><strong>+2.1%</strong></td>
<td align="center">-</td>
</tr>
<tr>
<td align="center">Knowledge Distillation(ResNet34-YOLOv3)+Pruning(FLOPs-67.56%)</td>
<td align="center"><strong>-0.3%</strong></td>
<td align="center"><strong>-66.90%</strong></td>
</tr>
</tbody>
</table></div>
</div>
<div class="section" id="nas">
<h3>NAS<a class="headerlink" href="#nas" title="Permalink to this headline"></a></h3>
<p>Dataset: ImageNet2012; Model: MobileNetV2</p>
<table border="1" class="docutils">
<thead>
<tr>
<th align="center">Device</th>
<th align="center">Infer time cost</th>
<th align="center">Top1 accuracy(baseline:71.90%)</th>
</tr>
</thead>
<tbody>
<tr>
<td align="center">RK3288</td>
<td align="center"><strong>-23%</strong></td>
<td align="center">+0.07%</td>
</tr>
<tr>
<td align="center">Android cellphone</td>
<td align="center"><strong>-20%</strong></td>
<td align="center">+0.16%</td>
</tr>
<tr>
<td align="center">iPhone 6s</td>
<td align="center"><strong>-17%</strong></td>
<td align="center">+0.32%</td>
</tr>
</tbody>
</table></div>
</div>
</div> </div>
......
...@@ -82,27 +82,29 @@ ...@@ -82,27 +82,29 @@
<ul class="current"> <ul class="current">
<li class="toctree-l1"><a class="reference internal" href="index_en.html">English Documents</a></li> <li class="toctree-l1"><a class="reference internal" href="index_en.html">English Documents</a></li>
<li class="toctree-l1"><a class="reference internal" href="intro.html">PaddleSlim简介</a></li> <li class="toctree-l1"><a class="reference internal" href="intro.html">介绍</a></li>
<li class="toctree-l1"><a class="reference internal" href="install.html">安装</a></li> <li class="toctree-l1"><a class="reference internal" href="install.html">安装</a></li>
<li class="toctree-l1"><a class="reference internal" href="quick_start/index.html">快速开始</a></li> <li class="toctree-l1"><a class="reference internal" href="quick_start/index.html">快速开始</a></li>
<li class="toctree-l1"><a class="reference internal" href="tutorials/index.html">进阶教程</a></li> <li class="toctree-l1"><a class="reference internal" href="tutorials/index.html">进阶教程</a></li>
<li class="toctree-l1"><a class="reference internal" href="api_cn/index.html">API文档</a></li> <li class="toctree-l1"><a class="reference internal" href="api_cn/index.html">API文档</a></li>
<li class="toctree-l1 current"><a class="current reference internal" href="#">模型库</a><ul> <li class="toctree-l1 current"><a class="current reference internal" href="#">模型库</a><ul>
<li class="toctree-l2"><a class="reference internal" href="#id2">1. 图分类</a><ul> <li class="toctree-l2"><a class="reference internal" href="#id2">1. 图分类</a><ul>
<li class="toctree-l3"><a class="reference internal" href="#id3">1.1 量化</a></li> <li class="toctree-l3"><a class="reference internal" href="#id3">1.1 量化</a></li>
<li class="toctree-l3"><a class="reference internal" href="#id4">1.2 剪裁</a></li> <li class="toctree-l3"><a class="reference internal" href="#id4">1.2 剪裁</a></li>
<li class="toctree-l3"><a class="reference internal" href="#id5">1.3 蒸馏</a></li> <li class="toctree-l3"><a class="reference internal" href="#id5">1.3 蒸馏</a></li>
<li class="toctree-l3"><a class="reference internal" href="#id6">1.4 搜索</a></li>
</ul> </ul>
</li> </li>
<li class="toctree-l2"><a class="reference internal" href="#id6">2. 目标检测</a><ul> <li class="toctree-l2"><a class="reference internal" href="#id7">2. 目标检测</a><ul>
<li class="toctree-l3"><a class="reference internal" href="#id7">2.1 量化</a></li> <li class="toctree-l3"><a class="reference internal" href="#id8">2.1 量化</a></li>
<li class="toctree-l3"><a class="reference internal" href="#id8">2.2 剪裁</a></li> <li class="toctree-l3"><a class="reference internal" href="#id9">2.2 剪裁</a></li>
<li class="toctree-l3"><a class="reference internal" href="#id9">2.3 蒸馏</a></li> <li class="toctree-l3"><a class="reference internal" href="#id10">2.3 蒸馏</a></li>
<li class="toctree-l3"><a class="reference internal" href="#id11">2.4 搜索</a></li>
</ul> </ul>
</li> </li>
<li class="toctree-l2"><a class="reference internal" href="#id10">3. 图像分割</a><ul> <li class="toctree-l2"><a class="reference internal" href="#id13">3. 图像分割</a><ul>
<li class="toctree-l3"><a class="reference internal" href="#id11">3.1 量化</a></li> <li class="toctree-l3"><a class="reference internal" href="#id14">3.1 量化</a></li>
<li class="toctree-l3"><a class="reference internal" href="#id12">3.2 剪裁</a></li> <li class="toctree-l3"><a class="reference internal" href="#id15">3.2 剪裁</a></li>
</ul> </ul>
</li> </li>
</ul> </ul>
...@@ -155,7 +157,7 @@ ...@@ -155,7 +157,7 @@
<div class="section" id="id1"> <div class="section" id="id1">
<h1>模型库<a class="headerlink" href="#id1" title="永久链接至标题"></a></h1> <h1>模型库<a class="headerlink" href="#id1" title="永久链接至标题"></a></h1>
<div class="section" id="id2"> <div class="section" id="id2">
<h2>1. 图分类<a class="headerlink" href="#id2" title="永久链接至标题"></a></h2> <h2>1. 图分类<a class="headerlink" href="#id2" title="永久链接至标题"></a></h2>
<p>数据集:ImageNet1000类</p> <p>数据集:ImageNet1000类</p>
<div class="section" id="id3"> <div class="section" id="id3">
<h3>1.1 量化<a class="headerlink" href="#id3" title="永久链接至标题"></a></h3> <h3>1.1 量化<a class="headerlink" href="#id3" title="永久链接至标题"></a></h3>
...@@ -561,6 +563,10 @@ ...@@ -561,6 +563,10 @@
</table></div> </table></div>
<div class="section" id="id4"> <div class="section" id="id4">
<h3>1.2 剪裁<a class="headerlink" href="#id4" title="永久链接至标题"></a></h3> <h3>1.2 剪裁<a class="headerlink" href="#id4" title="永久链接至标题"></a></h3>
<p>PaddleLite推理耗时说明:</p>
<p>环境:Qualcomm SnapDragon 845 + armv8</p>
<p>速度指标:Thread1/Thread2/Thread4耗时</p>
<p>PaddleLite版本: v2.3</p>
<table border="1" class="docutils"> <table border="1" class="docutils">
<thead> <thead>
<tr> <tr>
...@@ -569,6 +575,8 @@ ...@@ -569,6 +575,8 @@
<th align="center">Top-1/Top-5 Acc</th> <th align="center">Top-1/Top-5 Acc</th>
<th align="center">模型体积(MB)</th> <th align="center">模型体积(MB)</th>
<th align="center">GFLOPs</th> <th align="center">GFLOPs</th>
<th align="center">PaddleLite推理耗时</th>
<th align="center">TensorRT推理速度(FPS)</th>
<th align="center">下载</th> <th align="center">下载</th>
</tr> </tr>
</thead> </thead>
...@@ -579,6 +587,8 @@ ...@@ -579,6 +587,8 @@
<td align="center">70.99%/89.68%</td> <td align="center">70.99%/89.68%</td>
<td align="center">17</td> <td align="center">17</td>
<td align="center">1.11</td> <td align="center">1.11</td>
<td align="center">66.052\35.8014\19.5762</td>
<td align="center">-</td>
<td align="center"><a href="http://paddle-imagenet-models-name.bj.bcebos.com/MobileNetV1_pretrained.tar">下载链接</a></td> <td align="center"><a href="http://paddle-imagenet-models-name.bj.bcebos.com/MobileNetV1_pretrained.tar">下载链接</a></td>
</tr> </tr>
<tr> <tr>
...@@ -587,6 +597,8 @@ ...@@ -587,6 +597,8 @@
<td align="center">69.4%/88.66% (-1.59%/-1.02%)</td> <td align="center">69.4%/88.66% (-1.59%/-1.02%)</td>
<td align="center">9</td> <td align="center">9</td>
<td align="center">0.56</td> <td align="center">0.56</td>
<td align="center">33.5636\18.6834\10.5076</td>
<td align="center">-</td>
<td align="center"><a href="https://paddlemodels.bj.bcebos.com/PaddleSlim/MobileNetV1_uniform-50.tar">下载链接</a></td> <td align="center"><a href="https://paddlemodels.bj.bcebos.com/PaddleSlim/MobileNetV1_uniform-50.tar">下载链接</a></td>
</tr> </tr>
<tr> <tr>
...@@ -595,6 +607,8 @@ ...@@ -595,6 +607,8 @@
<td align="center">70.4%/89.3% (-0.59%/-0.38%)</td> <td align="center">70.4%/89.3% (-0.59%/-0.38%)</td>
<td align="center">12</td> <td align="center">12</td>
<td align="center">0.74</td> <td align="center">0.74</td>
<td align="center">46.5958\25.3098\13.6982</td>
<td align="center">-</td>
<td align="center"><a href="https://paddlemodels.bj.bcebos.com/PaddleSlim/MobileNetV1_sensitive-30.tar">下载链接</a></td> <td align="center"><a href="https://paddlemodels.bj.bcebos.com/PaddleSlim/MobileNetV1_sensitive-30.tar">下载链接</a></td>
</tr> </tr>
<tr> <tr>
...@@ -603,6 +617,8 @@ ...@@ -603,6 +617,8 @@
<td align="center">69.8% / 88.9% (-1.19%/-0.78%)</td> <td align="center">69.8% / 88.9% (-1.19%/-0.78%)</td>
<td align="center">9</td> <td align="center">9</td>
<td align="center">0.56</td> <td align="center">0.56</td>
<td align="center">37.9892\20.7882\11.3144</td>
<td align="center">-</td>
<td align="center"><a href="https://paddlemodels.bj.bcebos.com/PaddleSlim/MobileNetV1_sensitive-50.tar">下载链接</a></td> <td align="center"><a href="https://paddlemodels.bj.bcebos.com/PaddleSlim/MobileNetV1_sensitive-50.tar">下载链接</a></td>
</tr> </tr>
<tr> <tr>
...@@ -611,6 +627,8 @@ ...@@ -611,6 +627,8 @@
<td align="center">72.15%/90.65%</td> <td align="center">72.15%/90.65%</td>
<td align="center">15</td> <td align="center">15</td>
<td align="center">0.59</td> <td align="center">0.59</td>
<td align="center">41.7874\23.375\13.3998</td>
<td align="center">-</td>
<td align="center"><a href="https://paddle-imagenet-models-name.bj.bcebos.com/MobileNetV2_pretrained.tar">下载链接</a></td> <td align="center"><a href="https://paddle-imagenet-models-name.bj.bcebos.com/MobileNetV2_pretrained.tar">下载链接</a></td>
</tr> </tr>
<tr> <tr>
...@@ -619,6 +637,8 @@ ...@@ -619,6 +637,8 @@
<td align="center">65.79%/86.11% (-6.35%/-4.47%)</td> <td align="center">65.79%/86.11% (-6.35%/-4.47%)</td>
<td align="center">11</td> <td align="center">11</td>
<td align="center">0.296</td> <td align="center">0.296</td>
<td align="center">23.8842\13.8698\8.5572</td>
<td align="center">-</td>
<td align="center"><a href="https://paddlemodels.bj.bcebos.com/PaddleSlim/MobileNetV2_uniform-50.tar">下载链接</a></td> <td align="center"><a href="https://paddlemodels.bj.bcebos.com/PaddleSlim/MobileNetV2_uniform-50.tar">下载链接</a></td>
</tr> </tr>
<tr> <tr>
...@@ -627,6 +647,8 @@ ...@@ -627,6 +647,8 @@
<td align="center">72.15%/90.65%</td> <td align="center">72.15%/90.65%</td>
<td align="center">84</td> <td align="center">84</td>
<td align="center">7.36</td> <td align="center">7.36</td>
<td align="center">217.808\139.943\96.7504</td>
<td align="center">342.32</td>
<td align="center"><a href="https://paddle-imagenet-models-name.bj.bcebos.com/ResNet34_pretrained.tar">下载链接</a></td> <td align="center"><a href="https://paddle-imagenet-models-name.bj.bcebos.com/ResNet34_pretrained.tar">下载链接</a></td>
</tr> </tr>
<tr> <tr>
...@@ -635,6 +657,8 @@ ...@@ -635,6 +657,8 @@
<td align="center">70.99%/89.95% (-1.36%/-0.87%)</td> <td align="center">70.99%/89.95% (-1.36%/-0.87%)</td>
<td align="center">41</td> <td align="center">41</td>
<td align="center">3.67</td> <td align="center">3.67</td>
<td align="center">114.787\75.0332\51.8438</td>
<td align="center">452.41</td>
<td align="center"><a href="https://paddlemodels.bj.bcebos.com/PaddleSlim/ResNet34_uniform-50.tar">下载链接</a></td> <td align="center"><a href="https://paddlemodels.bj.bcebos.com/PaddleSlim/ResNet34_uniform-50.tar">下载链接</a></td>
</tr> </tr>
<tr> <tr>
...@@ -643,6 +667,8 @@ ...@@ -643,6 +667,8 @@
<td align="center">70.24%/89.63% (-2.04%/-1.06%)</td> <td align="center">70.24%/89.63% (-2.04%/-1.06%)</td>
<td align="center">33</td> <td align="center">33</td>
<td align="center">3.31</td> <td align="center">3.31</td>
<td align="center">105.924\69.3222\48.0246</td>
<td align="center">457.25</td>
<td align="center"><a href="https://paddlemodels.bj.bcebos.com/PaddleSlim/ResNet34_auto-55.tar">下载链接</a></td> <td align="center"><a href="https://paddlemodels.bj.bcebos.com/PaddleSlim/ResNet34_auto-55.tar">下载链接</a></td>
</tr> </tr>
</tbody> </tbody>
...@@ -717,16 +743,74 @@ ...@@ -717,16 +743,74 @@
<td align="center"><a href="https://paddlemodels.bj.bcebos.com/PaddleSlim/ResNet50_distilled.tar">下载链接</a></td> <td align="center"><a href="https://paddlemodels.bj.bcebos.com/PaddleSlim/ResNet50_distilled.tar">下载链接</a></td>
</tr> </tr>
</tbody> </tbody>
</table><p>!!! note &#8220;Note&#8220;</p> </table><p>注意:带&#8221;_vd&#8221;后缀代表该预训练模型使用了Mixup,Mixup相关介绍参考<a class="reference external" href="https://arxiv.org/abs/1710.09412">mixup: Beyond Empirical Risk Minimization</a></p>
<div class="highlight-default"><div class="highlight"><pre><span></span>&lt;a name=&quot;trans1&quot;&gt;[1]&lt;/a&gt;:带_vd后缀代表该预训练模型使用了Mixup,Mixup相关介绍参考[mixup: Beyond Empirical Risk Minimization](https://arxiv.org/abs/1710.09412)
</pre></div>
</div> </div>
<div class="section" id="id6">
<h3>1.4 搜索<a class="headerlink" href="#id6" title="永久链接至标题"></a></h3>
<p>数据集: ImageNet1000</p>
<table border="1" class="docutils">
<thead>
<tr>
<th align="center">模型</th>
<th align="center">压缩方法</th>
<th align="center">Top-1/Top-5 Acc</th>
<th align="center">模型体积(MB)</th>
<th align="center">GFLOPs</th>
<th align="center">下载</th>
</tr>
</thead>
<tbody>
<tr>
<td align="center">MobileNetV2</td>
<td align="center">-</td>
<td align="center">72.15%/90.65%</td>
<td align="center">15</td>
<td align="center">0.59</td>
<td align="center"><a href="https://paddle-imagenet-models-name.bj.bcebos.com/MobileNetV2_pretrained.tar">下载链接</a></td>
</tr>
<tr>
<td align="center">MobileNetV2</td>
<td align="center">SANAS</td>
<td align="center">71.518%/90.208% (-0.632%/-0.442%)</td>
<td align="center">14</td>
<td align="center">0.295</td>
<td align="center"><a href="https://paddlemodels.cdn.bcebos.com/PaddleSlim/MobileNetV2_sanas.tar">下载链接</a></td>
</tr>
</tbody>
</table><p>数据集: Cifar10</p>
<table border="1" class="docutils">
<thead>
<tr>
<th align="center">模型</th>
<th align="center">压缩方法</th>
<th align="center">Acc</th>
<th align="center">模型参数(MB)</th>
<th align="center">下载</th>
</tr>
</thead>
<tbody>
<tr>
<td align="center">Darts</td>
<td align="center">-</td>
<td align="center">97.135%</td>
<td align="center">3.767</td>
<td align="center">-</td>
</tr>
<tr>
<td align="center">Darts_SA(基于Darts搜索空间)</td>
<td align="center">SANAS</td>
<td align="center">97.276%(+0.141%)</td>
<td align="center">3.344(-11.2%)</td>
<td align="center">-</td>
</tr>
</tbody>
</table><p>Note: MobileNetV2_NAS 的token是:[4,&nbsp;4,&nbsp;5,&nbsp;1,&nbsp;1,&nbsp;2,&nbsp;1,&nbsp;1,&nbsp;0,&nbsp;2,&nbsp;6,&nbsp;2,&nbsp;0,&nbsp;3,&nbsp;4,&nbsp;5,&nbsp;0,&nbsp;4,&nbsp;5,&nbsp;5,&nbsp;1,&nbsp;4,&nbsp;8,&nbsp;0,&nbsp;0]. Darts_SA的token是:[5, 5, 0, 5, 5, 10, 7, 7, 5, 7, 7, 11, 10, 12, 10, 0, 5, 3, 10, 8].</p>
</div> </div>
</div> </div>
<div class="section" id="id6">
<h2>2. 目标检测<a class="headerlink" href="#id6" title="永久链接至标题"></a></h2>
<div class="section" id="id7"> <div class="section" id="id7">
<h3>2.1 量化<a class="headerlink" href="#id7" title="永久链接至标题"></a></h3> <h2>2. 目标检测<a class="headerlink" href="#id7" title="永久链接至标题"></a></h2>
<div class="section" id="id8">
<h3>2.1 量化<a class="headerlink" href="#id8" title="永久链接至标题"></a></h3>
<p>数据集: COCO 2017</p> <p>数据集: COCO 2017</p>
<table border="1" class="docutils"> <table border="1" class="docutils">
<thead> <thead>
...@@ -938,9 +1022,13 @@ ...@@ -938,9 +1022,13 @@
</tr> </tr>
</tbody> </tbody>
</table></div> </table></div>
<div class="section" id="id8"> <div class="section" id="id9">
<h3>2.2 剪裁<a class="headerlink" href="#id8" title="永久链接至标题"></a></h3> <h3>2.2 剪裁<a class="headerlink" href="#id9" title="永久链接至标题"></a></h3>
<p>数据集:Pasacl VOC &amp; COCO 2017</p> <p>数据集:Pasacl VOC &amp; COCO 2017</p>
<p>PaddleLite推理耗时说明:</p>
<p>环境:Qualcomm SnapDragon 845 + armv8</p>
<p>速度指标:Thread1/Thread2/Thread4耗时</p>
<p>PaddleLite版本: v2.3</p>
<table border="1" class="docutils"> <table border="1" class="docutils">
<thead> <thead>
<tr> <tr>
...@@ -953,6 +1041,8 @@ ...@@ -953,6 +1041,8 @@
<th align="center">输入320 Box AP</th> <th align="center">输入320 Box AP</th>
<th align="center">模型体积(MB)</th> <th align="center">模型体积(MB)</th>
<th align="center">GFLOPs (608*608)</th> <th align="center">GFLOPs (608*608)</th>
<th align="center">PaddleLite推理耗时(ms)(608*608)</th>
<th align="center">TensorRT推理速度(FPS)(608*608)</th>
<th align="center">下载</th> <th align="center">下载</th>
</tr> </tr>
</thead> </thead>
...@@ -967,6 +1057,8 @@ ...@@ -967,6 +1057,8 @@
<td align="center">75.3</td> <td align="center">75.3</td>
<td align="center">94</td> <td align="center">94</td>
<td align="center">40.49</td> <td align="center">40.49</td>
<td align="center">1238\796.943\520.101</td>
<td align="center">60.04</td>
<td align="center"><a href="https://paddlemodels.bj.bcebos.com/object_detection/yolov3_mobilenet_v1_voc.tar">下载链接</a></td> <td align="center"><a href="https://paddlemodels.bj.bcebos.com/object_detection/yolov3_mobilenet_v1_voc.tar">下载链接</a></td>
</tr> </tr>
<tr> <tr>
...@@ -979,6 +1071,8 @@ ...@@ -979,6 +1071,8 @@
<td align="center">75.5 (+0.2)</td> <td align="center">75.5 (+0.2)</td>
<td align="center">31</td> <td align="center">31</td>
<td align="center">19.08</td> <td align="center">19.08</td>
<td align="center">602.497\353.759\222.427</td>
<td align="center">99.36</td>
<td align="center"><a href="https://paddlemodels.bj.bcebos.com/PaddleSlim/yolov3_mobilenet_v1_voc_prune.tar">下载链接</a></td> <td align="center"><a href="https://paddlemodels.bj.bcebos.com/PaddleSlim/yolov3_mobilenet_v1_voc_prune.tar">下载链接</a></td>
</tr> </tr>
<tr> <tr>
...@@ -991,6 +1085,8 @@ ...@@ -991,6 +1085,8 @@
<td align="center">27.0</td> <td align="center">27.0</td>
<td align="center">95</td> <td align="center">95</td>
<td align="center">41.35</td> <td align="center">41.35</td>
<td align="center">-</td>
<td align="center">-</td>
<td align="center"><a href="https://paddlemodels.bj.bcebos.com/object_detection/yolov3_mobilenet_v1.tar">下载链接</a></td> <td align="center"><a href="https://paddlemodels.bj.bcebos.com/object_detection/yolov3_mobilenet_v1.tar">下载链接</a></td>
</tr> </tr>
<tr> <tr>
...@@ -1003,6 +1099,8 @@ ...@@ -1003,6 +1099,8 @@
<td align="center">22.6 (-4.4)</td> <td align="center">22.6 (-4.4)</td>
<td align="center">32</td> <td align="center">32</td>
<td align="center">19.94</td> <td align="center">19.94</td>
<td align="center">-</td>
<td align="center">73.93</td>
<td align="center"><a href="https://paddlemodels.bj.bcebos.com/PaddleSlim/yolov3_mobilenet_v1_prune.tar">下载链接</a></td> <td align="center"><a href="https://paddlemodels.bj.bcebos.com/PaddleSlim/yolov3_mobilenet_v1_prune.tar">下载链接</a></td>
</tr> </tr>
<tr> <tr>
...@@ -1015,6 +1113,8 @@ ...@@ -1015,6 +1113,8 @@
<td align="center">-</td> <td align="center">-</td>
<td align="center">177</td> <td align="center">177</td>
<td align="center">89.60</td> <td align="center">89.60</td>
<td align="center">-</td>
<td align="center">27.68</td>
<td align="center"><a href="https://paddlemodels.bj.bcebos.com/object_detection/yolov3_r50vd_dcn.tar">下载链接</a></td> <td align="center"><a href="https://paddlemodels.bj.bcebos.com/object_detection/yolov3_r50vd_dcn.tar">下载链接</a></td>
</tr> </tr>
<tr> <tr>
...@@ -1027,6 +1127,8 @@ ...@@ -1027,6 +1127,8 @@
<td align="center">-</td> <td align="center">-</td>
<td align="center">150</td> <td align="center">150</td>
<td align="center">81.20</td> <td align="center">81.20</td>
<td align="center">-</td>
<td align="center">30.08</td>
<td align="center"><a href="https://paddlemodels.bj.bcebos.com/PaddleSlim/yolov3_r50vd_dcn_prune.tar">下载链接</a></td> <td align="center"><a href="https://paddlemodels.bj.bcebos.com/PaddleSlim/yolov3_r50vd_dcn_prune.tar">下载链接</a></td>
</tr> </tr>
<tr> <tr>
...@@ -1039,6 +1141,8 @@ ...@@ -1039,6 +1141,8 @@
<td align="center">-</td> <td align="center">-</td>
<td align="center">113</td> <td align="center">113</td>
<td align="center">67.48</td> <td align="center">67.48</td>
<td align="center">-</td>
<td align="center">34.32</td>
<td align="center"><a href="https://paddlemodels.bj.bcebos.com/PaddleSlim/yolov3_r50vd_dcn_prune578.tar">下载链接</a></td> <td align="center"><a href="https://paddlemodels.bj.bcebos.com/PaddleSlim/yolov3_r50vd_dcn_prune578.tar">下载链接</a></td>
</tr> </tr>
<tr> <tr>
...@@ -1051,6 +1155,8 @@ ...@@ -1051,6 +1155,8 @@
<td align="center">-</td> <td align="center">-</td>
<td align="center">177</td> <td align="center">177</td>
<td align="center">89.60</td> <td align="center">89.60</td>
<td align="center">-</td>
<td align="center">-</td>
<td align="center"><a href="https://paddlemodels.bj.bcebos.com/object_detection/yolov3_r50vd_dcn_obj365_pretrained_coco.tar">下载链接</a></td> <td align="center"><a href="https://paddlemodels.bj.bcebos.com/object_detection/yolov3_r50vd_dcn_obj365_pretrained_coco.tar">下载链接</a></td>
</tr> </tr>
<tr> <tr>
...@@ -1063,6 +1169,8 @@ ...@@ -1063,6 +1169,8 @@
<td align="center">-</td> <td align="center">-</td>
<td align="center">150</td> <td align="center">150</td>
<td align="center">81.20</td> <td align="center">81.20</td>
<td align="center">-</td>
<td align="center">-</td>
<td align="center"><a href="https://paddlemodels.bj.bcebos.com/PaddleSlim/yolov3_r50vd_dcn_obj365_pretrained_coco_prune.tar">下载链接</a></td> <td align="center"><a href="https://paddlemodels.bj.bcebos.com/PaddleSlim/yolov3_r50vd_dcn_obj365_pretrained_coco_prune.tar">下载链接</a></td>
</tr> </tr>
<tr> <tr>
...@@ -1075,12 +1183,14 @@ ...@@ -1075,12 +1183,14 @@
<td align="center">-</td> <td align="center">-</td>
<td align="center">113</td> <td align="center">113</td>
<td align="center">67.48</td> <td align="center">67.48</td>
<td align="center">-</td>
<td align="center">-</td>
<td align="center"><a href="https://paddlemodels.bj.bcebos.com/PaddleSlim/yolov3_r50vd_dcn_obj365_pretrained_coco_prune578.tar">下载链接</a></td> <td align="center"><a href="https://paddlemodels.bj.bcebos.com/PaddleSlim/yolov3_r50vd_dcn_obj365_pretrained_coco_prune578.tar">下载链接</a></td>
</tr> </tr>
</tbody> </tbody>
</table></div> </table></div>
<div class="section" id="id9"> <div class="section" id="id10">
<h3>2.3 蒸馏<a class="headerlink" href="#id9" title="永久链接至标题"></a></h3> <h3>2.3 蒸馏<a class="headerlink" href="#id10" title="永久链接至标题"></a></h3>
<p>数据集:Pasacl VOC &amp; COCO 2017</p> <p>数据集:Pasacl VOC &amp; COCO 2017</p>
<table border="1" class="docutils"> <table border="1" class="docutils">
<thead> <thead>
...@@ -1165,12 +1275,62 @@ ...@@ -1165,12 +1275,62 @@
</tr> </tr>
</tbody> </tbody>
</table></div> </table></div>
<div class="section" id="id11">
<h3>2.4 搜索<a class="headerlink" href="#id11" title="永久链接至标题"></a></h3>
<p>数据集:WIDER-FACE</p>
<table border="1" class="docutils">
<thead>
<tr>
<th align="center">模型</th>
<th align="center">压缩方法</th>
<th align="center">Image/GPU</th>
<th align="center">输入尺寸</th>
<th align="center">Easy/Medium/Hard</th>
<th align="center">模型体积(KB)</th>
<th align="center">硬件延时(ms)</th>
<th align="center">下载</th>
</tr>
</thead>
<tbody>
<tr>
<td align="center">BlazeFace</td>
<td align="center">-</td>
<td align="center">8</td>
<td align="center">640</td>
<td align="center">91.5/89.2/79.7</td>
<td align="center">815</td>
<td align="center">71.862</td>
<td align="center"><a href="https://paddlemodels.bj.bcebos.com/object_detection/blazeface_original.tar">下载链接</a></td>
</tr>
<tr>
<td align="center">BlazeFace-NAS</td>
<td align="center">-</td>
<td align="center">8</td>
<td align="center">640</td>
<td align="center">83.7/80.7/65.8</td>
<td align="center">244</td>
<td align="center">21.117</td>
<td align="center"><a href="https://paddlemodels.bj.bcebos.com/object_detection/blazeface_nas.tar">下载链接</a></td>
</tr>
<tr>
<td align="center">BlazeFace-NASV2</td>
<td align="center">SANAS</td>
<td align="center">8</td>
<td align="center">640</td>
<td align="center">87.0/83.7/68.5</td>
<td align="center">389</td>
<td align="center">22.558</td>
<td align="center"><a href="https://paddlemodels.bj.bcebos.com/object_detection/blazeface_nas2.tar">下载链接</a></td>
</tr>
</tbody>
</table><p>Note: 硬件延时时间是利用提供的硬件延时表得到的,硬件延时表是在855芯片上基于PaddleLite测试的结果。BlazeFace-NASV2的详细配置在<a class="reference external" href="https://github.com/PaddlePaddle/PaddleDetection/blob/master/configs/face_detection/blazeface_nas_v2.yml">这里</a>.</p>
</div> </div>
<div class="section" id="id10"> </div>
<h2>3. 图像分割<a class="headerlink" href="#id10" title="永久链接至标题"></a></h2> <div class="section" id="id13">
<h2>3. 图像分割<a class="headerlink" href="#id13" title="永久链接至标题"></a></h2>
<p>数据集:Cityscapes</p> <p>数据集:Cityscapes</p>
<div class="section" id="id11"> <div class="section" id="id14">
<h3>3.1 量化<a class="headerlink" href="#id11" title="永久链接至标题"></a></h3> <h3>3.1 量化<a class="headerlink" href="#id14" title="永久链接至标题"></a></h3>
<table border="1" class="docutils"> <table border="1" class="docutils">
<thead> <thead>
<tr> <tr>
...@@ -1441,8 +1601,12 @@ ...@@ -1441,8 +1601,12 @@
</tr> </tr>
</tbody> </tbody>
</table></div> </table></div>
<div class="section" id="id12"> <div class="section" id="id15">
<h3>3.2 剪裁<a class="headerlink" href="#id12" title="永久链接至标题"></a></h3> <h3>3.2 剪裁<a class="headerlink" href="#id15" title="永久链接至标题"></a></h3>
<p>PaddleLite推理耗时说明:</p>
<p>环境:Qualcomm SnapDragon 845 + armv8</p>
<p>速度指标:Thread1/Thread2/Thread4耗时</p>
<p>PaddleLite版本: v2.3</p>
<table border="1" class="docutils"> <table border="1" class="docutils">
<thead> <thead>
<tr> <tr>
...@@ -1451,6 +1615,8 @@ ...@@ -1451,6 +1615,8 @@
<th align="center">mIoU</th> <th align="center">mIoU</th>
<th align="center">模型体积(MB)</th> <th align="center">模型体积(MB)</th>
<th align="center">GFLOPs</th> <th align="center">GFLOPs</th>
<th align="center">PaddleLite推理耗时</th>
<th align="center">TensorRT推理速度(FPS)</th>
<th align="center">下载</th> <th align="center">下载</th>
</tr> </tr>
</thead> </thead>
...@@ -1461,6 +1627,8 @@ ...@@ -1461,6 +1627,8 @@
<td align="center">69.64</td> <td align="center">69.64</td>
<td align="center">11</td> <td align="center">11</td>
<td align="center">14.41</td> <td align="center">14.41</td>
<td align="center">1226.36\682.96\415.664</td>
<td align="center">39.53</td>
<td align="center"><a href="https://paddlemodels.bj.bcebos.com/PaddleSlim/fast_scnn_cityscape.tar">下载链接</a></td> <td align="center"><a href="https://paddlemodels.bj.bcebos.com/PaddleSlim/fast_scnn_cityscape.tar">下载链接</a></td>
</tr> </tr>
<tr> <tr>
...@@ -1469,6 +1637,8 @@ ...@@ -1469,6 +1637,8 @@
<td align="center">69.58 (-0.06)</td> <td align="center">69.58 (-0.06)</td>
<td align="center">8.5</td> <td align="center">8.5</td>
<td align="center">11.95</td> <td align="center">11.95</td>
<td align="center">1140.37\656.612\415.888</td>
<td align="center">42.01</td>
<td align="center"><a href="https://paddlemodels.bj.bcebos.com/PaddleSlim/fast_scnn_cityscape_uniform-17.tar">下载链接</a></td> <td align="center"><a href="https://paddlemodels.bj.bcebos.com/PaddleSlim/fast_scnn_cityscape_uniform-17.tar">下载链接</a></td>
</tr> </tr>
<tr> <tr>
...@@ -1477,6 +1647,8 @@ ...@@ -1477,6 +1647,8 @@
<td align="center">66.68 (-2.96)</td> <td align="center">66.68 (-2.96)</td>
<td align="center">5.7</td> <td align="center">5.7</td>
<td align="center">7.55</td> <td align="center">7.55</td>
<td align="center">866.693\494.467\291.748</td>
<td align="center">51.48</td>
<td align="center"><a href="https://paddlemodels.bj.bcebos.com/PaddleSlim/fast_scnn_cityscape_sensitive-47.tar">下载链接</a></td> <td align="center"><a href="https://paddlemodels.bj.bcebos.com/PaddleSlim/fast_scnn_cityscape_sensitive-47.tar">下载链接</a></td>
</tr> </tr>
</tbody> </tbody>
......
...@@ -34,7 +34,7 @@ ...@@ -34,7 +34,7 @@
href="genindex.html"/> href="genindex.html"/>
<link rel="search" title="Search" href="search.html"/> <link rel="search" title="Search" href="search.html"/>
<link rel="top" title="PaddleSlim 1.0 documentation" href="index.html"/> <link rel="top" title="PaddleSlim 1.0 documentation" href="index.html"/>
<link rel="prev" title="search space" href="api_en/search_space_en.html"/> <link rel="prev" title="Table about hardware lantency" href="api_en/table_latency_en.html"/>
<script src="_static/js/modernizr.min.js"></script> <script src="_static/js/modernizr.min.js"></script>
...@@ -87,21 +87,23 @@ ...@@ -87,21 +87,23 @@
<li class="toctree-l1"><a class="reference internal" href="tutorials/index_en.html">Aadvanced Tutorials</a></li> <li class="toctree-l1"><a class="reference internal" href="tutorials/index_en.html">Aadvanced Tutorials</a></li>
<li class="toctree-l1"><a class="reference internal" href="api_en/index_en.html">API Documents</a></li> <li class="toctree-l1"><a class="reference internal" href="api_en/index_en.html">API Documents</a></li>
<li class="toctree-l1 current"><a class="current reference internal" href="#">Model Zoo</a><ul> <li class="toctree-l1 current"><a class="current reference internal" href="#">Model Zoo</a><ul>
<li class="toctree-l2"><a class="reference internal" href="#id1">1. 图象分类</a><ul> <li class="toctree-l2"><a class="reference internal" href="#image-classification">1. Image Classification</a><ul>
<li class="toctree-l3"><a class="reference internal" href="#id2">1.1 量化</a></li> <li class="toctree-l3"><a class="reference internal" href="#quantization">1.1 Quantization</a></li>
<li class="toctree-l3"><a class="reference internal" href="#id3">1.2 剪裁</a></li> <li class="toctree-l3"><a class="reference internal" href="#pruning">1.2 Pruning</a></li>
<li class="toctree-l3"><a class="reference internal" href="#id4">1.3 蒸馏</a></li> <li class="toctree-l3"><a class="reference internal" href="#distillation">1.3 Distillation</a></li>
<li class="toctree-l3"><a class="reference internal" href="#nas">1.4 NAS</a></li>
</ul> </ul>
</li> </li>
<li class="toctree-l2"><a class="reference internal" href="#id5">2. 目标检测</a><ul> <li class="toctree-l2"><a class="reference internal" href="#object-detection">2. Object Detection</a><ul>
<li class="toctree-l3"><a class="reference internal" href="#id6">2.1 量化</a></li> <li class="toctree-l3"><a class="reference internal" href="#id1">2.1 Quantization</a></li>
<li class="toctree-l3"><a class="reference internal" href="#id7">2.2 剪裁</a></li> <li class="toctree-l3"><a class="reference internal" href="#id2">2.2 Pruning</a></li>
<li class="toctree-l3"><a class="reference internal" href="#id8">2.3 蒸馏</a></li> <li class="toctree-l3"><a class="reference internal" href="#id3">2.3 Distillation</a></li>
<li class="toctree-l3"><a class="reference internal" href="#id4">2.4 NAS</a></li>
</ul> </ul>
</li> </li>
<li class="toctree-l2"><a class="reference internal" href="#id9">3. 图像分割</a><ul> <li class="toctree-l2"><a class="reference internal" href="#image-segmentation">3. Image Segmentation</a><ul>
<li class="toctree-l3"><a class="reference internal" href="#id10">3.1 量化</a></li> <li class="toctree-l3"><a class="reference internal" href="#id5">3.1 Quantization</a></li>
<li class="toctree-l3"><a class="reference internal" href="#id11">3.2 剪裁</a></li> <li class="toctree-l3"><a class="reference internal" href="#id6">3.2 Pruning</a></li>
</ul> </ul>
</li> </li>
</ul> </ul>
...@@ -152,19 +154,20 @@ ...@@ -152,19 +154,20 @@
<div class="section" id="model-zoo"> <div class="section" id="model-zoo">
<h1>Model Zoo<a class="headerlink" href="#model-zoo" title="Permalink to this headline"></a></h1> <h1>Model Zoo<a class="headerlink" href="#model-zoo" title="Permalink to this headline"></a></h1>
<div class="section" id="id1"> <div class="section" id="image-classification">
<h2>1. 图象分类<a class="headerlink" href="#id1" title="Permalink to this headline"></a></h2> <h2>1. Image Classification<a class="headerlink" href="#image-classification" title="Permalink to this headline"></a></h2>
<p>数据集:ImageNet1000类</p> <p>Dataset:ImageNet1000</p>
<div class="section" id="id2"> <div class="section" id="quantization">
<h3>1.1 量化<a class="headerlink" href="#id2" title="Permalink to this headline"></a></h3> <h3>1.1 Quantization<a class="headerlink" href="#quantization" title="Permalink to this headline"></a></h3>
<table border="1" class="docutils"> <table border="1" class="docutils">
<thead> <thead>
<tr> <tr>
<th align="center">模型</th> <th align="center">Model</th>
<th align="center">压缩方法</th> <th align="center">Method</th>
<th align="center">Top-1/Top-5 Acc</th> <th align="center">Top-1/Top-5 Acc</th>
<th align="center">模型体积(MB)</th> <th align="center">Model Size(MB)</th>
<th align="center">下载</th> <th align="center">TensorRT latency(V100, ms)</th>
<th align="center">Download</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
...@@ -172,78 +175,407 @@ ...@@ -172,78 +175,407 @@
<td align="center">MobileNetV1</td> <td align="center">MobileNetV1</td>
<td align="center">-</td> <td align="center">-</td>
<td align="center">70.99%/89.68%</td> <td align="center">70.99%/89.68%</td>
<td align="center">xx</td> <td align="center">17</td>
<td align="center"><a href="">下载链接</a></td> <td align="center">-</td>
<td align="center"><a href="http://paddle-imagenet-models-name.bj.bcebos.com/MobileNetV1_pretrained.tar">model</a></td>
</tr> </tr>
<tr> <tr>
<td align="center">MobileNetV1</td> <td align="center">MobileNetV1</td>
<td align="center">quant_post</td> <td align="center">quant_post</td>
<td align="center">xx%/xx%</td> <td align="center">70.18%/89.25% (-0.81%/-0.43%)</td>
<td align="center">xx</td> <td align="center">4.4</td>
<td align="center"><a href="">下载链接</a></td> <td align="center">-</td>
<td align="center"><a href="https://paddlemodels.bj.bcebos.com/PaddleSlim/MobileNetV1_quant_post.tar">model</a></td>
</tr> </tr>
<tr> <tr>
<td align="center">MobileNetV1</td> <td align="center">MobileNetV1</td>
<td align="center">quant_aware</td> <td align="center">quant_aware</td>
<td align="center">xx%/xx%</td> <td align="center">70.60%/89.57% (-0.39%/-0.11%)</td>
<td align="center">xx</td> <td align="center">4.4</td>
<td align="center"><a href="">下载链接</a></td> <td align="center">-</td>
<td align="center"><a href="https://paddlemodels.bj.bcebos.com/PaddleSlim/MobileNetV1_quant_aware.tar">model</a></td>
</tr> </tr>
<tr> <tr>
<td align="center">MobileNetV2</td> <td align="center">MobileNetV2</td>
<td align="center">-</td> <td align="center">-</td>
<td align="center">72.15%/90.65%</td> <td align="center">72.15%/90.65%</td>
<td align="center">xx</td> <td align="center">15</td>
<td align="center"><a href="">下载链接</a></td> <td align="center">-</td>
<td align="center"><a href="https://paddle-imagenet-models-name.bj.bcebos.com/MobileNetV2_pretrained.tar">model</a></td>
</tr> </tr>
<tr> <tr>
<td align="center">MobileNetV2</td> <td align="center">MobileNetV2</td>
<td align="center">quant_post</td> <td align="center">quant_post</td>
<td align="center">xx%/xx%</td> <td align="center">71.15%/90.11% (-1%/-0.54%)</td>
<td align="center">xx</td> <td align="center">4.0</td>
<td align="center"><a href="">下载链接</a></td> <td align="center">-</td>
<td align="center"><a href="https://paddlemodels.bj.bcebos.com/PaddleSlim/MobileNetV2_quant_post.tar">model</a></td>
</tr> </tr>
<tr> <tr>
<td align="center">MobileNetV2</td> <td align="center">MobileNetV2</td>
<td align="center">quant_aware</td> <td align="center">quant_aware</td>
<td align="center">xx%/xx%</td> <td align="center">72.05%/90.63% (-0.1%/-0.02%)</td>
<td align="center">xx</td> <td align="center">4.0</td>
<td align="center"><a href="">下载链接</a></td> <td align="center">-</td>
<td align="center"><a href="https://paddlemodels.bj.bcebos.com/PaddleSlim/MobileNetV2_quant_aware.tar">model</a></td>
</tr> </tr>
<tr> <tr>
<td align="center">ResNet50</td> <td align="center">ResNet50</td>
<td align="center">-</td> <td align="center">-</td>
<td align="center">76.50%/93.00%</td> <td align="center">76.50%/93.00%</td>
<td align="center">xx</td> <td align="center">99</td>
<td align="center"><a href="">下载链接</a></td> <td align="center">2.71</td>
<td align="center"><a href="http://paddle-imagenet-models-name.bj.bcebos.com/ResNet50_pretrained.tar">model</a></td>
</tr> </tr>
<tr> <tr>
<td align="center">ResNet50</td> <td align="center">ResNet50</td>
<td align="center">quant_post</td> <td align="center">quant_post</td>
<td align="center">xx%/xx%</td> <td align="center">76.33%/93.02% (-0.17%/+0.02%)</td>
<td align="center">xx</td> <td align="center">25.1</td>
<td align="center"><a href="">下载链接</a></td> <td align="center">1.19</td>
<td align="center"><a href="https://paddlemodels.bj.bcebos.com/PaddleSlim/ResNet50_quant_post.tar">model</a></td>
</tr> </tr>
<tr> <tr>
<td align="center">ResNet50</td> <td align="center">ResNet50</td>
<td align="center">quant_aware</td> <td align="center">quant_aware</td>
<td align="center">xx%/xx%</td> <td align="center">76.48%/93.11% (-0.02%/+0.11%)</td>
<td align="center">xx</td> <td align="center">25.1</td>
<td align="center"><a href="">下载链接</a></td> <td align="center">1.17</td>
<td align="center"><a href="https://paddlemodels.bj.bcebos.com/PaddleSlim/ResNet50_quant_awre.tar">model</a></td>
</tr>
</tbody>
</table><p>PaddleLite latency(ms)</p>
<table border="1" class="docutils">
<thead>
<tr>
<th>Device</th>
<th>Model</th>
<th>Method</th>
<th>armv7 Thread 1</th>
<th>armv7 Thread 2</th>
<th>armv7 Thread 4</th>
<th>armv8 Thread 1</th>
<th>armv8 Thread 2</th>
<th>armv8 Thread 4</th>
</tr>
</thead>
<tbody>
<tr>
<td>Qualcomm 835</td>
<td>MobileNetV1</td>
<td>FP32 baseline</td>
<td>96.1942</td>
<td>53.2058</td>
<td>32.4468</td>
<td>88.4955</td>
<td>47.95</td>
<td>27.5189</td>
</tr>
<tr>
<td>Qualcomm 835</td>
<td>MobileNetV1</td>
<td>quant_aware</td>
<td>60.8186</td>
<td>32.1931</td>
<td>16.4275</td>
<td>56.4311</td>
<td>29.5446</td>
<td>15.1053</td>
</tr>
<tr>
<td>Qualcomm 835</td>
<td>MobileNetV1</td>
<td>quant_post</td>
<td>60.5615</td>
<td>32.4016</td>
<td>16.6596</td>
<td>56.5266</td>
<td>29.7178</td>
<td>15.1459</td>
</tr>
<tr>
<td>Qualcomm 835</td>
<td>MobileNetV2</td>
<td>FP32 baseline</td>
<td>65.715</td>
<td>38.1346</td>
<td>25.155</td>
<td>61.3593</td>
<td>36.2038</td>
<td>22.849</td>
</tr>
<tr>
<td>Qualcomm 835</td>
<td>MobileNetV2</td>
<td>quant_aware</td>
<td>48.3655</td>
<td>30.2021</td>
<td>21.9303</td>
<td>46.1487</td>
<td>27.3146</td>
<td>18.3053</td>
</tr>
<tr>
<td>Qualcomm 835</td>
<td>MobileNetV2</td>
<td>quant_post</td>
<td>48.3495</td>
<td>30.3069</td>
<td>22.1506</td>
<td>45.8715</td>
<td>27.4105</td>
<td>18.2223</td>
</tr>
<tr>
<td>Qualcomm 835</td>
<td>ResNet50</td>
<td>FP32 baseline</td>
<td>526.811</td>
<td>319.6486</td>
<td>205.8345</td>
<td>506.1138</td>
<td>335.1584</td>
<td>214.8936</td>
</tr>
<tr>
<td>Qualcomm 835</td>
<td>ResNet50</td>
<td>quant_aware</td>
<td>475.4538</td>
<td>256.8672</td>
<td>139.699</td>
<td>461.7344</td>
<td>247.9506</td>
<td>145.9847</td>
</tr>
<tr>
<td>Qualcomm 835</td>
<td>ResNet50</td>
<td>quant_post</td>
<td>476.0507</td>
<td>256.5963</td>
<td>139.7266</td>
<td>461.9176</td>
<td>248.3795</td>
<td>149.353</td>
</tr>
<tr>
<td>Qualcomm 855</td>
<td>MobileNetV1</td>
<td>FP32 baseline</td>
<td>33.5086</td>
<td>19.5773</td>
<td>11.7534</td>
<td>31.3474</td>
<td>18.5382</td>
<td>10.0811</td>
</tr>
<tr>
<td>Qualcomm 855</td>
<td>MobileNetV1</td>
<td>quant_aware</td>
<td>36.7067</td>
<td>21.628</td>
<td>11.0372</td>
<td>14.0238</td>
<td>8.199</td>
<td>4.2588</td>
</tr>
<tr>
<td>Qualcomm 855</td>
<td>MobileNetV1</td>
<td>quant_post</td>
<td>37.0498</td>
<td>21.7081</td>
<td>11.0779</td>
<td>14.0947</td>
<td>8.1926</td>
<td>4.2934</td>
</tr>
<tr>
<td>Qualcomm 855</td>
<td>MobileNetV2</td>
<td>FP32 baseline</td>
<td>25.0396</td>
<td>15.2862</td>
<td>9.6609</td>
<td>22.909</td>
<td>14.1797</td>
<td>8.8325</td>
</tr>
<tr>
<td>Qualcomm 855</td>
<td>MobileNetV2</td>
<td>quant_aware</td>
<td>28.1583</td>
<td>18.3317</td>
<td>11.8103</td>
<td>16.9158</td>
<td>11.1606</td>
<td>7.4148</td>
</tr>
<tr>
<td>Qualcomm 855</td>
<td>MobileNetV2</td>
<td>quant_post</td>
<td>28.1631</td>
<td>18.3917</td>
<td>11.8333</td>
<td>16.9399</td>
<td>11.1772</td>
<td>7.4176</td>
</tr>
<tr>
<td>Qualcomm 855</td>
<td>ResNet50</td>
<td>FP32 baseline</td>
<td>185.3705</td>
<td>113.0825</td>
<td>87.0741</td>
<td>177.7367</td>
<td>110.0433</td>
<td>74.4114</td>
</tr>
<tr>
<td>Qualcomm 855</td>
<td>ResNet50</td>
<td>quant_aware</td>
<td>327.6883</td>
<td>202.4536</td>
<td>106.243</td>
<td>243.5621</td>
<td>150.0542</td>
<td>78.4205</td>
</tr>
<tr>
<td>Qualcomm 855</td>
<td>ResNet50</td>
<td>quant_post</td>
<td>328.2683</td>
<td>201.9937</td>
<td>106.744</td>
<td>242.6397</td>
<td>150.0338</td>
<td>79.8659</td>
</tr>
<tr>
<td>Kirin 970</td>
<td>MobileNetV1</td>
<td>FP32 baseline</td>
<td>101.2455</td>
<td>56.4053</td>
<td>35.6484</td>
<td>94.8985</td>
<td>51.7251</td>
<td>31.9511</td>
</tr>
<tr>
<td>Kirin 970</td>
<td>MobileNetV1</td>
<td>quant_aware</td>
<td>62.5012</td>
<td>32.1863</td>
<td>16.6018</td>
<td>57.7477</td>
<td>29.2116</td>
<td>15.0703</td>
</tr>
<tr>
<td>Kirin 970</td>
<td>MobileNetV1</td>
<td>quant_post</td>
<td>62.4412</td>
<td>32.2585</td>
<td>16.6215</td>
<td>57.825</td>
<td>29.2573</td>
<td>15.1206</td>
</tr>
<tr>
<td>Kirin 970</td>
<td>MobileNetV2</td>
<td>FP32 baseline</td>
<td>70.4176</td>
<td>42.0795</td>
<td>25.1939</td>
<td>68.9597</td>
<td>39.2145</td>
<td>22.6617</td>
</tr>
<tr>
<td>Kirin 970</td>
<td>MobileNetV2</td>
<td>quant_aware</td>
<td>52.9961</td>
<td>31.5323</td>
<td>22.1447</td>
<td>49.4858</td>
<td>28.0856</td>
<td>18.7287</td>
</tr>
<tr>
<td>Kirin 970</td>
<td>MobileNetV2</td>
<td>quant_post</td>
<td>53.0961</td>
<td>31.7987</td>
<td>21.8334</td>
<td>49.383</td>
<td>28.2358</td>
<td>18.3642</td>
</tr>
<tr>
<td>Kirin 970</td>
<td>ResNet50</td>
<td>FP32 baseline</td>
<td>586.8943</td>
<td>344.0858</td>
<td>228.2293</td>
<td>573.3344</td>
<td>351.4332</td>
<td>225.8006</td>
</tr>
<tr>
<td>Kirin 970</td>
<td>ResNet50</td>
<td>quant_aware</td>
<td>488.361</td>
<td>260.1697</td>
<td>142.416</td>
<td>479.5668</td>
<td>249.8485</td>
<td>138.1742</td>
</tr>
<tr>
<td>Kirin 970</td>
<td>ResNet50</td>
<td>quant_post</td>
<td>489.6188</td>
<td>258.3279</td>
<td>142.6063</td>
<td>480.0064</td>
<td>249.5339</td>
<td>138.5284</td>
</tr> </tr>
</tbody> </tbody>
</table></div> </table></div>
<div class="section" id="id3"> <div class="section" id="pruning">
<h3>1.2 剪裁<a class="headerlink" href="#id3" title="Permalink to this headline"></a></h3> <h3>1.2 Pruning<a class="headerlink" href="#pruning" title="Permalink to this headline"></a></h3>
<p>PaddleLite:</p>
<p>env: Qualcomm SnapDragon 845 + armv8</p>
<p>criterion: time cost in Thread1/Thread2/Thread4</p>
<p>PaddleLite version: v2.3</p>
<table border="1" class="docutils"> <table border="1" class="docutils">
<thead> <thead>
<tr> <tr>
<th align="center">模型</th> <th align="center">Model</th>
<th align="center">压缩方法</th> <th align="center">Method</th>
<th align="center">Top-1/Top-5 Acc</th> <th align="center">Top-1/Top-5 Acc</th>
<th align="center">模型体积(MB)</th> <th align="center">ModelSize(MB)</th>
<th align="center">GFLOPs</th> <th align="center">GFLOPs</th>
<th align="center">下载</th> <th align="center">PaddleLite cost(ms)</th>
<th align="center">TensorRT speed(FPS)</th>
<th align="center">download</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
...@@ -253,7 +585,9 @@ ...@@ -253,7 +585,9 @@
<td align="center">70.99%/89.68%</td> <td align="center">70.99%/89.68%</td>
<td align="center">17</td> <td align="center">17</td>
<td align="center">1.11</td> <td align="center">1.11</td>
<td align="center"><a href="http://paddle-imagenet-models-name.bj.bcebos.com/MobileNetV1_pretrained.tar">下载链接</a></td> <td align="center">66.052\35.8014\19.5762</td>
<td align="center">-</td>
<td align="center"><a href="http://paddle-imagenet-models-name.bj.bcebos.com/MobileNetV1_pretrained.tar">download</a></td>
</tr> </tr>
<tr> <tr>
<td align="center">MobileNetV1</td> <td align="center">MobileNetV1</td>
...@@ -261,7 +595,9 @@ ...@@ -261,7 +595,9 @@
<td align="center">69.4%/88.66% (-1.59%/-1.02%)</td> <td align="center">69.4%/88.66% (-1.59%/-1.02%)</td>
<td align="center">9</td> <td align="center">9</td>
<td align="center">0.56</td> <td align="center">0.56</td>
<td align="center"><a href="https://paddlemodels.bj.bcebos.com/PaddleSlim/MobileNetV1_uniform-50.tar">下载链接</a></td> <td align="center">33.5636\18.6834\10.5076</td>
<td align="center">-</td>
<td align="center"><a href="https://paddlemodels.bj.bcebos.com/PaddleSlim/MobileNetV1_uniform-50.tar">download</a></td>
</tr> </tr>
<tr> <tr>
<td align="center">MobileNetV1</td> <td align="center">MobileNetV1</td>
...@@ -269,7 +605,9 @@ ...@@ -269,7 +605,9 @@
<td align="center">70.4%/89.3% (-0.59%/-0.38%)</td> <td align="center">70.4%/89.3% (-0.59%/-0.38%)</td>
<td align="center">12</td> <td align="center">12</td>
<td align="center">0.74</td> <td align="center">0.74</td>
<td align="center"><a href="https://paddlemodels.bj.bcebos.com/PaddleSlim/MobileNetV1_sensitive-30.tar">下载链接</a></td> <td align="center">46.5958\25.3098\13.6982</td>
<td align="center">-</td>
<td align="center"><a href="https://paddlemodels.bj.bcebos.com/PaddleSlim/MobileNetV1_sensitive-30.tar">download</a></td>
</tr> </tr>
<tr> <tr>
<td align="center">MobileNetV1</td> <td align="center">MobileNetV1</td>
...@@ -277,7 +615,9 @@ ...@@ -277,7 +615,9 @@
<td align="center">69.8% / 88.9% (-1.19%/-0.78%)</td> <td align="center">69.8% / 88.9% (-1.19%/-0.78%)</td>
<td align="center">9</td> <td align="center">9</td>
<td align="center">0.56</td> <td align="center">0.56</td>
<td align="center"><a href="https://paddlemodels.bj.bcebos.com/PaddleSlim/MobileNetV1_sensitive-50.tar">下载链接</a></td> <td align="center">37.9892\20.7882\11.3144</td>
<td align="center">-</td>
<td align="center"><a href="https://paddlemodels.bj.bcebos.com/PaddleSlim/MobileNetV1_sensitive-50.tar">download</a></td>
</tr> </tr>
<tr> <tr>
<td align="center">MobileNetV2</td> <td align="center">MobileNetV2</td>
...@@ -285,7 +625,9 @@ ...@@ -285,7 +625,9 @@
<td align="center">72.15%/90.65%</td> <td align="center">72.15%/90.65%</td>
<td align="center">15</td> <td align="center">15</td>
<td align="center">0.59</td> <td align="center">0.59</td>
<td align="center"><a href="https://paddle-imagenet-models-name.bj.bcebos.com/MobileNetV2_pretrained.tar">下载链接</a></td> <td align="center">41.7874\23.375\13.3998</td>
<td align="center">-</td>
<td align="center"><a href="https://paddle-imagenet-models-name.bj.bcebos.com/MobileNetV2_pretrained.tar">download</a></td>
</tr> </tr>
<tr> <tr>
<td align="center">MobileNetV2</td> <td align="center">MobileNetV2</td>
...@@ -293,7 +635,9 @@ ...@@ -293,7 +635,9 @@
<td align="center">65.79%/86.11% (-6.35%/-4.47%)</td> <td align="center">65.79%/86.11% (-6.35%/-4.47%)</td>
<td align="center">11</td> <td align="center">11</td>
<td align="center">0.296</td> <td align="center">0.296</td>
<td align="center"><a href="https://paddlemodels.bj.bcebos.com/PaddleSlim/MobileNetV2_uniform-50.tar">下载链接</a></td> <td align="center">23.8842\13.8698\8.5572</td>
<td align="center">-</td>
<td align="center"><a href="https://paddlemodels.bj.bcebos.com/PaddleSlim/MobileNetV2_uniform-50.tar">download</a></td>
</tr> </tr>
<tr> <tr>
<td align="center">ResNet34</td> <td align="center">ResNet34</td>
...@@ -301,7 +645,9 @@ ...@@ -301,7 +645,9 @@
<td align="center">72.15%/90.65%</td> <td align="center">72.15%/90.65%</td>
<td align="center">84</td> <td align="center">84</td>
<td align="center">7.36</td> <td align="center">7.36</td>
<td align="center"><a href="https://paddle-imagenet-models-name.bj.bcebos.com/ResNet34_pretrained.tar">下载链接</a></td> <td align="center">217.808\139.943\96.7504</td>
<td align="center">342.32</td>
<td align="center"><a href="https://paddle-imagenet-models-name.bj.bcebos.com/ResNet34_pretrained.tar">download</a></td>
</tr> </tr>
<tr> <tr>
<td align="center">ResNet34</td> <td align="center">ResNet34</td>
...@@ -309,7 +655,9 @@ ...@@ -309,7 +655,9 @@
<td align="center">70.99%/89.95% (-1.36%/-0.87%)</td> <td align="center">70.99%/89.95% (-1.36%/-0.87%)</td>
<td align="center">41</td> <td align="center">41</td>
<td align="center">3.67</td> <td align="center">3.67</td>
<td align="center"><a href="https://paddlemodels.bj.bcebos.com/PaddleSlim/ResNet34_uniform-50.tar">下载链接</a></td> <td align="center">114.787\75.0332\51.8438</td>
<td align="center">452.41</td>
<td align="center"><a href="https://paddlemodels.bj.bcebos.com/PaddleSlim/ResNet34_uniform-50.tar">download</a></td>
</tr> </tr>
<tr> <tr>
<td align="center">ResNet34</td> <td align="center">ResNet34</td>
...@@ -317,20 +665,22 @@ ...@@ -317,20 +665,22 @@
<td align="center">70.24%/89.63% (-2.04%/-1.06%)</td> <td align="center">70.24%/89.63% (-2.04%/-1.06%)</td>
<td align="center">33</td> <td align="center">33</td>
<td align="center">3.31</td> <td align="center">3.31</td>
<td align="center"><a href="https://paddlemodels.bj.bcebos.com/PaddleSlim/ResNet34_auto-55.tar">下载链接</a></td> <td align="center">105.924\69.3222\48.0246</td>
<td align="center">457.25</td>
<td align="center"><a href="https://paddlemodels.bj.bcebos.com/PaddleSlim/ResNet34_auto-55.tar">download</a></td>
</tr> </tr>
</tbody> </tbody>
</table></div> </table></div>
<div class="section" id="id4"> <div class="section" id="distillation">
<h3>1.3 蒸馏<a class="headerlink" href="#id4" title="Permalink to this headline"></a></h3> <h3>1.3 Distillation<a class="headerlink" href="#distillation" title="Permalink to this headline"></a></h3>
<table border="1" class="docutils"> <table border="1" class="docutils">
<thead> <thead>
<tr> <tr>
<th align="center">模型</th> <th align="center">Model</th>
<th align="center">压缩方法</th> <th align="center">Method</th>
<th align="center">Top-1/Top-5 Acc</th> <th align="center">Top-1/Top-5 Acc</th>
<th align="center">模型体积(MB)</th> <th align="center">Model Size(MB)</th>
<th align="center">下载</th> <th align="center">Download</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
...@@ -339,81 +689,117 @@ ...@@ -339,81 +689,117 @@
<td align="center">student</td> <td align="center">student</td>
<td align="center">70.99%/89.68%</td> <td align="center">70.99%/89.68%</td>
<td align="center">17</td> <td align="center">17</td>
<td align="center"><a href="http://paddle-imagenet-models-name.bj.bcebos.com/MobileNetV1_pretrained.tar">下载链接</a></td> <td align="center"><a href="http://paddle-imagenet-models-name.bj.bcebos.com/MobileNetV1_pretrained.tar">model</a></td>
</tr> </tr>
<tr> <tr>
<td align="center">ResNet50_vd</td> <td align="center">ResNet50_vd</td>
<td align="center">teacher</td> <td align="center">teacher</td>
<td align="center">79.12%/94.44%</td> <td align="center">79.12%/94.44%</td>
<td align="center">99</td> <td align="center">99</td>
<td align="center"><a href="https://paddle-imagenet-models-name.bj.bcebos.com/ResNet50_vd_pretrained.tar">下载链接</a></td> <td align="center"><a href="https://paddle-imagenet-models-name.bj.bcebos.com/ResNet50_vd_pretrained.tar">model</a></td>
</tr> </tr>
<tr> <tr>
<td align="center">MobileNetV1</td> <td align="center">MobileNetV1</td>
<td align="center">ResNet50_vd<sup><a href="#trans1">1</a></sup> distill</td> <td align="center">ResNet50_vd<sup><a href="#trans1">1</a></sup> distill</td>
<td align="center">72.77%/90.68% (+1.78%/+1.00%)</td> <td align="center">72.77%/90.68% (+1.78%/+1.00%)</td>
<td align="center">17</td> <td align="center">17</td>
<td align="center"><a href="https://paddlemodels.bj.bcebos.com/PaddleSlim/MobileNetV1_distilled.tar">下载链接</a></td> <td align="center"><a href="https://paddlemodels.bj.bcebos.com/PaddleSlim/MobileNetV1_distilled.tar">model</a></td>
</tr> </tr>
<tr> <tr>
<td align="center">MobileNetV2</td> <td align="center">MobileNetV2</td>
<td align="center">student</td> <td align="center">student</td>
<td align="center">72.15%/90.65%</td> <td align="center">72.15%/90.65%</td>
<td align="center">15</td> <td align="center">15</td>
<td align="center"><a href="https://paddle-imagenet-models-name.bj.bcebos.com/MobileNetV2_pretrained.tar">下载链接</a></td> <td align="center"><a href="https://paddle-imagenet-models-name.bj.bcebos.com/MobileNetV2_pretrained.tar">model</a></td>
</tr> </tr>
<tr> <tr>
<td align="center">MobileNetV2</td> <td align="center">MobileNetV2</td>
<td align="center">ResNet50_vd distill</td> <td align="center">ResNet50_vd distill</td>
<td align="center">74.28%/91.53% (+2.13%/+0.88%)</td> <td align="center">74.28%/91.53% (+2.13%/+0.88%)</td>
<td align="center">15</td> <td align="center">15</td>
<td align="center"><a href="https://paddlemodels.bj.bcebos.com/PaddleSlim/MobileNetV2_distilled.tar">下载链接</a></td> <td align="center"><a href="https://paddlemodels.bj.bcebos.com/PaddleSlim/MobileNetV2_distilled.tar">model</a></td>
</tr> </tr>
<tr> <tr>
<td align="center">ResNet50</td> <td align="center">ResNet50</td>
<td align="center">student</td> <td align="center">student</td>
<td align="center">76.50%/93.00%</td> <td align="center">76.50%/93.00%</td>
<td align="center">99</td> <td align="center">99</td>
<td align="center"><a href="http://paddle-imagenet-models-name.bj.bcebos.com/ResNet50_pretrained.tar">下载链接</a></td> <td align="center"><a href="http://paddle-imagenet-models-name.bj.bcebos.com/ResNet50_pretrained.tar">model</a></td>
</tr> </tr>
<tr> <tr>
<td align="center">ResNet101</td> <td align="center">ResNet101</td>
<td align="center">teacher</td> <td align="center">teacher</td>
<td align="center">77.56%/93.64%</td> <td align="center">77.56%/93.64%</td>
<td align="center">173</td> <td align="center">173</td>
<td align="center"><a href="http://paddle-imagenet-models-name.bj.bcebos.com/ResNet101_pretrained.tar">下载链接</a></td> <td align="center"><a href="http://paddle-imagenet-models-name.bj.bcebos.com/ResNet101_pretrained.tar">model</a></td>
</tr> </tr>
<tr> <tr>
<td align="center">ResNet50</td> <td align="center">ResNet50</td>
<td align="center">ResNet101 distill</td> <td align="center">ResNet101 distill</td>
<td align="center">77.29%/93.65% (+0.79%/+0.65%)</td> <td align="center">77.29%/93.65% (+0.79%/+0.65%)</td>
<td align="center">99</td> <td align="center">99</td>
<td align="center"><a href="https://paddlemodels.bj.bcebos.com/PaddleSlim/ResNet50_distilled.tar">下载链接</a></td> <td align="center"><a href="https://paddlemodels.bj.bcebos.com/PaddleSlim/ResNet50_distilled.tar">model</a></td>
</tr> </tr>
</tbody> </tbody>
</table><p>!!! note &#8220;Note&#8220;</p> </table><p>Note: The <code class="docutils literal"><span class="pre">_vd</span></code> suffix indicates that the pre-trained model uses Mixup. Please refer to the detailed introduction: <a class="reference external" href="https://arxiv.org/abs/1710.09412">mixup: Beyond Empirical Risk Minimization</a></p>
<div class="highlight-default"><div class="highlight"><pre><span></span>&lt;a name=&quot;trans1&quot;&gt;[1]&lt;/a&gt;:带_vd后缀代表该预训练模型使用了Mixup,Mixup相关介绍参考[mixup: Beyond Empirical Risk Minimization](https://arxiv.org/abs/1710.09412)
</pre></div>
</div> </div>
<div class="section" id="nas">
<h3>1.4 NAS<a class="headerlink" href="#nas" title="Permalink to this headline"></a></h3>
<table border="1" class="docutils">
<thead>
<tr>
<th align="center">Model</th>
<th align="center">Method</th>
<th align="center">Top-1/Top-5 Acc</th>
<th align="center">Volume(MB)</th>
<th align="center">GFLOPs</th>
<th align="center">Download</th>
</tr>
</thead>
<tbody>
<tr>
<td align="center">MobileNetV2</td>
<td align="center">-</td>
<td align="center">72.15%/90.65%</td>
<td align="center">15</td>
<td align="center">0.59</td>
<td align="center"><a href="https://paddle-imagenet-models-name.bj.bcebos.com/MobileNetV2_pretrained.tar">model</a></td>
</tr>
<tr>
<td align="center">MobileNetV2_NAS</td>
<td align="center">SANAS</td>
<td align="center">71.518%/90.208% (-0.632%/-0.442%)</td>
<td align="center">14</td>
<td align="center">0.295</td>
<td align="center"><a href="https://paddlemodels.cdn.bcebos.com/PaddleSlim/MobileNetV2_sanas.tar">model</a></td>
</tr>
</tbody>
</table><p>Dataset: Cifar10
| Model | Method | Acc | Params(MB) | Download |
<a href="#id7"><span class="problematic" id="id8">|:&#8212;:|</span></a>:&#8211;:<a href="#id9"><span class="problematic" id="id10">|:&#8211;:|</span></a>:&#8211;:<a href="#id11"><span class="problematic" id="id12">|:&#8211;:|</span></a>
| Darts | - | 97.135% | 3.767 | - |
| Darts_SA(Based on Darts) | SANAS | 97.276%(+0.141%) | 3.344(-11.2%) | - |</p>
<p>Note: The token of MobileNetV2_NAS is [4,&nbsp;4,&nbsp;5,&nbsp;1,&nbsp;1,&nbsp;2,&nbsp;1,&nbsp;1,&nbsp;0,&nbsp;2,&nbsp;6,&nbsp;2,&nbsp;0,&nbsp;3,&nbsp;4,&nbsp;5,&nbsp;0,&nbsp;4,&nbsp;5,&nbsp;5,&nbsp;1,&nbsp;4,&nbsp;8,&nbsp;0,&nbsp;0]. The token of Darts_SA is [5, 5, 0, 5, 5, 10, 7, 7, 5, 7, 7, 11, 10, 12, 10, 0, 5, 3, 10, 8].</p>
</div> </div>
</div> </div>
<div class="section" id="id5"> <div class="section" id="object-detection">
<h2>2. 目标检测<a class="headerlink" href="#id5" title="Permalink to this headline"></a></h2> <h2>2. Object Detection<a class="headerlink" href="#object-detection" title="Permalink to this headline"></a></h2>
<div class="section" id="id6"> <div class="section" id="id1">
<h3>2.1 量化<a class="headerlink" href="#id6" title="Permalink to this headline"></a></h3> <h3>2.1 Quantization<a class="headerlink" href="#id1" title="Permalink to this headline"></a></h3>
<p>数据集: COCO 2017</p> <p>Dataset: COCO 2017</p>
<table border="1" class="docutils"> <table border="1" class="docutils">
<thead> <thead>
<tr> <tr>
<th align="center">模型</th> <th align="center">Model</th>
<th align="center">压缩方法</th> <th align="center">Method</th>
<th align="center">数据集</th> <th align="center">Dataset</th>
<th align="center">Image/GPU</th> <th align="center">Image/GPU</th>
<th align="center">输入608 Box AP</th> <th align="center">Input 608 Box AP</th>
<th align="center">输入416 Box AP</th> <th align="center">Input 416 Box AP</th>
<th align="center">输入320 Box AP</th> <th align="center">Input 320 Box AP</th>
<th align="center">模型体积(MB)</th> <th align="center">Model Size(MB)</th>
<th align="center">下载</th> <th align="center">TensorRT latency(V100, ms)</th>
<th align="center">Download</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
...@@ -425,76 +811,106 @@ ...@@ -425,76 +811,106 @@
<td align="center">29.3</td> <td align="center">29.3</td>
<td align="center">29.3</td> <td align="center">29.3</td>
<td align="center">27.1</td> <td align="center">27.1</td>
<td align="center">xx</td> <td align="center">95</td>
<td align="center"><a href="">下载链接</a></td> <td align="center">-</td>
<td align="center"><a href="https://paddlemodels.bj.bcebos.com/object_detection/yolov3_mobilenet_v1.tar">model</a></td>
</tr> </tr>
<tr> <tr>
<td align="center">MobileNet-V1-YOLOv3</td> <td align="center">MobileNet-V1-YOLOv3</td>
<td align="center">quant_post</td> <td align="center">quant_post</td>
<td align="center">COCO</td> <td align="center">COCO</td>
<td align="center">8</td> <td align="center">8</td>
<td align="center">xx</td> <td align="center">27.9 (-1.4)</td>
<td align="center">xx</td> <td align="center">28.0 (-1.3)</td>
<td align="center">xx</td> <td align="center">26.0 (-1.0)</td>
<td align="center">xx</td> <td align="center">25</td>
<td align="center"><a href="">下载链接</a></td> <td align="center">-</td>
<td align="center"><a href="https://paddlemodels.bj.bcebos.com/PaddleSlim/yolov3_mobilenetv1_coco_quant_post.tar">model</a></td>
</tr> </tr>
<tr> <tr>
<td align="center">MobileNet-V1-YOLOv3</td> <td align="center">MobileNet-V1-YOLOv3</td>
<td align="center">quant_aware</td> <td align="center">quant_aware</td>
<td align="center">COCO</td> <td align="center">COCO</td>
<td align="center">8</td> <td align="center">8</td>
<td align="center">xx</td> <td align="center">28.1 (-1.2)</td>
<td align="center">xx</td> <td align="center">28.2 (-1.1)</td>
<td align="center">xx</td> <td align="center">25.8 (-1.2)</td>
<td align="center">xx</td> <td align="center">26.3</td>
<td align="center"><a href="">下载链接</a></td> <td align="center">-</td>
<td align="center"><a href="https://paddlemodels.bj.bcebos.com/PaddleSlim/yolov3_mobilenet_coco_quant_aware.tar">model</a></td>
</tr> </tr>
<tr> <tr>
<td align="center">R50-dcn-YOLOv3 obj365_pretrain</td> <td align="center">R34-YOLOv3</td>
<td align="center">-</td> <td align="center">-</td>
<td align="center">COCO</td> <td align="center">COCO</td>
<td align="center">8</td> <td align="center">8</td>
<td align="center">41.4</td> <td align="center">36.2</td>
<td align="center">xx</td> <td align="center">34.3</td>
<td align="center">xx</td> <td align="center">31.4</td>
<td align="center">xx</td> <td align="center">162</td>
<td align="center"><a href="">下载链接</a></td> <td align="center">-</td>
<td align="center"><a href="https://paddlemodels.bj.bcebos.com/object_detection/yolov3_r34.tar">model</a></td>
</tr> </tr>
<tr> <tr>
<td align="center">R50-dcn-YOLOv3 obj365_pretrain</td> <td align="center">R34-YOLOv3</td>
<td align="center">quant_post</td> <td align="center">quant_post</td>
<td align="center">COCO</td> <td align="center">COCO</td>
<td align="center">8</td> <td align="center">8</td>
<td align="center">xx</td> <td align="center">35.7 (-0.5)</td>
<td align="center">xx</td> <td align="center">-</td>
<td align="center">xx</td> <td align="center">-</td>
<td align="center">xx</td> <td align="center">42.7</td>
<td align="center"><a href="">下载链接</a></td> <td align="center">-</td>
<td align="center"><a href="https://paddlemodels.bj.bcebos.com/PaddleSlim/yolov3_r34_coco_quant_post.tar">model</a></td>
</tr>
<tr>
<td align="center">R34-YOLOv3</td>
<td align="center">quant_aware</td>
<td align="center">COCO</td>
<td align="center">8</td>
<td align="center">35.2 (-1.0)</td>
<td align="center">33.3 (-1.0)</td>
<td align="center">30.3 (-1.1)</td>
<td align="center">44</td>
<td align="center">-</td>
<td align="center"><a href="https://paddlemodels.bj.bcebos.com/PaddleSlim/yolov3_r34_coco_quant_aware.tar">model</a></td>
</tr>
<tr>
<td align="center">R50-dcn-YOLOv3 obj365_pretrain</td>
<td align="center">-</td>
<td align="center">COCO</td>
<td align="center">8</td>
<td align="center">41.4</td>
<td align="center">-</td>
<td align="center">-</td>
<td align="center">177</td>
<td align="center">18.56</td>
<td align="center"><a href="https://paddlemodels.bj.bcebos.com/object_detection/yolov3_r50vd_dcn_obj365_pretrained_coco.tar">model</a></td>
</tr> </tr>
<tr> <tr>
<td align="center">R50-dcn-YOLOv3 obj365_pretrain</td> <td align="center">R50-dcn-YOLOv3 obj365_pretrain</td>
<td align="center">quant_aware</td> <td align="center">quant_aware</td>
<td align="center">COCO</td> <td align="center">COCO</td>
<td align="center">8</td> <td align="center">8</td>
<td align="center">xx</td> <td align="center">40.6 (-0.8)</td>
<td align="center">xx</td> <td align="center">37.5</td>
<td align="center">xx</td> <td align="center">34.1</td>
<td align="center">xx</td> <td align="center">66</td>
<td align="center"><a href="">下载链接</a></td> <td align="center">14.64</td>
<td align="center"><a href="https://paddlemodels.bj.bcebos.com/PaddleSlim/yolov3_r50vd_dcn_obj365_pretrained_coco_quant_aware.tar">model</a></td>
</tr> </tr>
</tbody> </tbody>
</table><p>数据集:WIDER-FACE</p> </table><p>Dataset:WIDER-FACE</p>
<table border="1" class="docutils"> <table border="1" class="docutils">
<thead> <thead>
<tr> <tr>
<th align="center">模型</th> <th align="center">Model</th>
<th align="center">压缩方法</th> <th align="center">Method</th>
<th align="center">Image/GPU</th> <th align="center">Image/GPU</th>
<th align="center">输入尺寸</th> <th align="center">Input Size</th>
<th align="center">Easy/Medium/Hard</th> <th align="center">Easy/Medium/Hard</th>
<th align="center">模型体积(MB)</th> <th align="center">Model Size(MB)</th>
<th align="center">下载</th> <th align="center">Download</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
...@@ -503,100 +919,106 @@ ...@@ -503,100 +919,106 @@
<td align="center">-</td> <td align="center">-</td>
<td align="center">8</td> <td align="center">8</td>
<td align="center">640</td> <td align="center">640</td>
<td align="center">0.915/0.892/0.797</td> <td align="center">91.5/89.2/79.7</td>
<td align="center">xx</td> <td align="center">815</td>
<td align="center"><a href="">下载链接</a></td> <td align="center"><a href="https://paddlemodels.bj.bcebos.com/object_detection/blazeface_original.tar">model</a></td>
</tr> </tr>
<tr> <tr>
<td align="center">BlazeFace</td> <td align="center">BlazeFace</td>
<td align="center">quant_post</td> <td align="center">quant_post</td>
<td align="center">8</td> <td align="center">8</td>
<td align="center">640</td> <td align="center">640</td>
<td align="center">xx/xx/xx</td> <td align="center">87.8/85.1/74.9 (-3.7/-4.1/-4.8)</td>
<td align="center">xx</td> <td align="center">228</td>
<td align="center"><a href="">下载链接</a></td> <td align="center"><a href="https://paddlemodels.bj.bcebos.com/PaddleSlim/blazeface_origin_quant_post.tar">model</a></td>
</tr> </tr>
<tr> <tr>
<td align="center">BlazeFace</td> <td align="center">BlazeFace</td>
<td align="center">quant_aware</td> <td align="center">quant_aware</td>
<td align="center">8</td> <td align="center">8</td>
<td align="center">640</td> <td align="center">640</td>
<td align="center">xx/xx/xx</td> <td align="center">90.5/87.9/77.6 (-1.0/-1.3/-2.1)</td>
<td align="center">xx</td> <td align="center">228</td>
<td align="center"><a href="">下载链接</a></td> <td align="center"><a href="https://paddlemodels.bj.bcebos.com/PaddleSlim/blazeface_origin_quant_aware.tar">model</a></td>
</tr> </tr>
<tr> <tr>
<td align="center">BlazeFace-Lite</td> <td align="center">BlazeFace-Lite</td>
<td align="center">-</td> <td align="center">-</td>
<td align="center">8</td> <td align="center">8</td>
<td align="center">640</td> <td align="center">640</td>
<td align="center">0.909/0.885/0.781</td> <td align="center">90.9/88.5/78.1</td>
<td align="center">xx</td> <td align="center">711</td>
<td align="center"><a href="">下载链接</a></td> <td align="center"><a href="https://paddlemodels.bj.bcebos.com/object_detection/blazeface_lite.tar">model</a></td>
</tr> </tr>
<tr> <tr>
<td align="center">BlazeFace-Lite</td> <td align="center">BlazeFace-Lite</td>
<td align="center">quant_post</td> <td align="center">quant_post</td>
<td align="center">8</td> <td align="center">8</td>
<td align="center">640</td> <td align="center">640</td>
<td align="center">xx/xx/xx</td> <td align="center">89.4/86.7/75.7 (-1.5/-1.8/-2.4)</td>
<td align="center">xx</td> <td align="center">211</td>
<td align="center"><a href="">下载链接</a></td> <td align="center"><a href="(https://paddlemodels.bj.bcebos.com/PaddleSlim/blazeface_lite_quant_post.tar)">model</a></td>
</tr> </tr>
<tr> <tr>
<td align="center">BlazeFace-Lite</td> <td align="center">BlazeFace-Lite</td>
<td align="center">quant_aware</td> <td align="center">quant_aware</td>
<td align="center">8</td> <td align="center">8</td>
<td align="center">640</td> <td align="center">640</td>
<td align="center">xx/xx/xx</td> <td align="center">89.7/87.3/77.0 (-1.2/-1.2/-1.1)</td>
<td align="center">xx</td> <td align="center">211</td>
<td align="center"><a href="">下载链接</a></td> <td align="center"><a href="https://paddlemodels.bj.bcebos.com/PaddleSlim/blazeface_lite_quant_aware.tar">model</a></td>
</tr> </tr>
<tr> <tr>
<td align="center">BlazeFace-NAS</td> <td align="center">BlazeFace-NAS</td>
<td align="center">-</td> <td align="center">-</td>
<td align="center">8</td> <td align="center">8</td>
<td align="center">640</td> <td align="center">640</td>
<td align="center">0.837/0.807/0.658</td> <td align="center">83.7/80.7/65.8</td>
<td align="center">xx</td> <td align="center">244</td>
<td align="center"><a href="">下载链接</a></td> <td align="center"><a href="https://paddlemodels.bj.bcebos.com/object_detection/blazeface_nas.tar">model</a></td>
</tr> </tr>
<tr> <tr>
<td align="center">BlazeFace-NAS</td> <td align="center">BlazeFace-NAS</td>
<td align="center">quant_post</td> <td align="center">quant_post</td>
<td align="center">8</td> <td align="center">8</td>
<td align="center">640</td> <td align="center">640</td>
<td align="center">xx/xx/xx</td> <td align="center">81.6/78.3/63.6 (-2.1/-2.4/-2.2)</td>
<td align="center">xx</td> <td align="center">71</td>
<td align="center"><a href="">下载链接</a></td> <td align="center"><a href="https://paddlemodels.bj.bcebos.com/PaddleSlim/blazeface_nas_quant_post.tar">model</a></td>
</tr> </tr>
<tr> <tr>
<td align="center">BlazeFace-NAS</td> <td align="center">BlazeFace-NAS</td>
<td align="center">quant_aware</td> <td align="center">quant_aware</td>
<td align="center">8</td> <td align="center">8</td>
<td align="center">640</td> <td align="center">640</td>
<td align="center">xx/xx/xx</td> <td align="center">83.1/79.7/64.2 (-0.6/-1.0/-1.6)</td>
<td align="center">xx</td> <td align="center">71</td>
<td align="center"><a href="">下载链接</a></td> <td align="center"><a href="https://paddlemodels.bj.bcebos.com/PaddleSlim/blazeface_nas_quant_aware.tar">model</a></td>
</tr> </tr>
</tbody> </tbody>
</table></div> </table></div>
<div class="section" id="id7"> <div class="section" id="id2">
<h3>2.2 剪裁<a class="headerlink" href="#id7" title="Permalink to this headline"></a></h3> <h3>2.2 Pruning<a class="headerlink" href="#id2" title="Permalink to this headline"></a></h3>
<p>数据集:Pasacl VOC &amp; COCO 2017</p> <p>Dataset:Pasacl VOC &amp; COCO 2017</p>
<p>PaddleLite:</p>
<p>env: Qualcomm SnapDragon 845 + armv8</p>
<p>criterion: time cost in Thread1/Thread2/Thread4</p>
<p>PaddleLite version: v2.3</p>
<table border="1" class="docutils"> <table border="1" class="docutils">
<thead> <thead>
<tr> <tr>
<th align="center">模型</th> <th align="center">Model</th>
<th align="center">压缩方法</th> <th align="center">Method</th>
<th align="center">数据集</th> <th align="center">Dataset</th>
<th align="center">Image/GPU</th> <th align="center">Image/GPU</th>
<th align="center">输入608 Box AP</th> <th align="center">Input 608 Box AP</th>
<th align="center">输入416 Box AP</th> <th align="center">Input 416 Box AP</th>
<th align="center">输入320 Box AP</th> <th align="center">Input 320 Box AP</th>
<th align="center">模型体积(MB)</th> <th align="center">Model Size(MB)</th>
<th align="center">GFLOPs (608*608)</th> <th align="center">GFLOPs (608*608)</th>
<th align="center">下载</th> <th align="center">PaddleLite cost(ms)(608*608)</th>
<th align="center">TensorRT speed(FPS)(608*608)</th>
<th align="center">Download</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
...@@ -610,7 +1032,9 @@ ...@@ -610,7 +1032,9 @@
<td align="center">75.3</td> <td align="center">75.3</td>
<td align="center">94</td> <td align="center">94</td>
<td align="center">40.49</td> <td align="center">40.49</td>
<td align="center"><a href="https://paddlemodels.bj.bcebos.com/object_detection/yolov3_mobilenet_v1_voc.tar">下载链接</a></td> <td align="center">1238\796.943\520.101</td>
<td align="center">60.40</td>
<td align="center"><a href="https://paddlemodels.bj.bcebos.com/object_detection/yolov3_mobilenet_v1_voc.tar">model</a></td>
</tr> </tr>
<tr> <tr>
<td align="center">MobileNet-V1-YOLOv3</td> <td align="center">MobileNet-V1-YOLOv3</td>
...@@ -622,7 +1046,9 @@ ...@@ -622,7 +1046,9 @@
<td align="center">75.5 (+0.2)</td> <td align="center">75.5 (+0.2)</td>
<td align="center">31</td> <td align="center">31</td>
<td align="center">19.08</td> <td align="center">19.08</td>
<td align="center"><a href="https://paddlemodels.bj.bcebos.com/PaddleSlim/yolov3_mobilenet_v1_voc_prune.tar">下载链接</a></td> <td align="center">602.497\353.759\222.427</td>
<td align="center">99.36</td>
<td align="center"><a href="https://paddlemodels.bj.bcebos.com/PaddleSlim/yolov3_mobilenet_v1_voc_prune.tar">model</a></td>
</tr> </tr>
<tr> <tr>
<td align="center">MobileNet-V1-YOLOv3</td> <td align="center">MobileNet-V1-YOLOv3</td>
...@@ -634,7 +1060,9 @@ ...@@ -634,7 +1060,9 @@
<td align="center">27.0</td> <td align="center">27.0</td>
<td align="center">95</td> <td align="center">95</td>
<td align="center">41.35</td> <td align="center">41.35</td>
<td align="center"><a href="https://paddlemodels.bj.bcebos.com/object_detection/yolov3_mobilenet_v1.tar">下载链接</a></td> <td align="center">-</td>
<td align="center">-</td>
<td align="center"><a href="https://paddlemodels.bj.bcebos.com/object_detection/yolov3_mobilenet_v1.tar">model</a></td>
</tr> </tr>
<tr> <tr>
<td align="center">MobileNet-V1-YOLOv3</td> <td align="center">MobileNet-V1-YOLOv3</td>
...@@ -646,7 +1074,9 @@ ...@@ -646,7 +1074,9 @@
<td align="center">22.6 (-4.4)</td> <td align="center">22.6 (-4.4)</td>
<td align="center">32</td> <td align="center">32</td>
<td align="center">19.94</td> <td align="center">19.94</td>
<td align="center"><a href="https://paddlemodels.bj.bcebos.com/PaddleSlim/yolov3_mobilenet_v1_prune.tar">下载链接</a></td> <td align="center">-</td>
<td align="center">73.93</td>
<td align="center"><a href="https://paddlemodels.bj.bcebos.com/PaddleSlim/yolov3_mobilenet_v1_prune.tar">model</a></td>
</tr> </tr>
<tr> <tr>
<td align="center">R50-dcn-YOLOv3</td> <td align="center">R50-dcn-YOLOv3</td>
...@@ -658,7 +1088,9 @@ ...@@ -658,7 +1088,9 @@
<td align="center">-</td> <td align="center">-</td>
<td align="center">177</td> <td align="center">177</td>
<td align="center">89.60</td> <td align="center">89.60</td>
<td align="center"><a href="https://paddlemodels.bj.bcebos.com/object_detection/yolov3_r50vd_dcn.tar">下载链接</a></td> <td align="center">-</td>
<td align="center">27.68</td>
<td align="center"><a href="https://paddlemodels.bj.bcebos.com/object_detection/yolov3_r50vd_dcn.tar">model</a></td>
</tr> </tr>
<tr> <tr>
<td align="center">R50-dcn-YOLOv3</td> <td align="center">R50-dcn-YOLOv3</td>
...@@ -670,7 +1102,9 @@ ...@@ -670,7 +1102,9 @@
<td align="center">-</td> <td align="center">-</td>
<td align="center">150</td> <td align="center">150</td>
<td align="center">81.20</td> <td align="center">81.20</td>
<td align="center"><a href="https://paddlemodels.bj.bcebos.com/PaddleSlim/yolov3_r50vd_dcn_prune.tar">下载链接</a></td> <td align="center">-</td>
<td align="center">30.08</td>
<td align="center"><a href="https://paddlemodels.bj.bcebos.com/PaddleSlim/yolov3_r50vd_dcn_prune.tar">model</a></td>
</tr> </tr>
<tr> <tr>
<td align="center">R50-dcn-YOLOv3</td> <td align="center">R50-dcn-YOLOv3</td>
...@@ -682,7 +1116,9 @@ ...@@ -682,7 +1116,9 @@
<td align="center">-</td> <td align="center">-</td>
<td align="center">113</td> <td align="center">113</td>
<td align="center">67.48</td> <td align="center">67.48</td>
<td align="center"><a href="https://paddlemodels.bj.bcebos.com/PaddleSlim/yolov3_r50vd_dcn_prune578.tar">下载链接</a></td> <td align="center">-</td>
<td align="center">34.32</td>
<td align="center"><a href="https://paddlemodels.bj.bcebos.com/PaddleSlim/yolov3_r50vd_dcn_prune578.tar">model</a></td>
</tr> </tr>
<tr> <tr>
<td align="center">R50-dcn-YOLOv3 obj365_pretrain</td> <td align="center">R50-dcn-YOLOv3 obj365_pretrain</td>
...@@ -694,7 +1130,9 @@ ...@@ -694,7 +1130,9 @@
<td align="center">-</td> <td align="center">-</td>
<td align="center">177</td> <td align="center">177</td>
<td align="center">89.60</td> <td align="center">89.60</td>
<td align="center"><a href="https://paddlemodels.bj.bcebos.com/object_detection/yolov3_r50vd_dcn_obj365_pretrained_coco.tar">下载链接</a></td> <td align="center">-</td>
<td align="center">-</td>
<td align="center"><a href="https://paddlemodels.bj.bcebos.com/object_detection/yolov3_r50vd_dcn_obj365_pretrained_coco.tar">model</a></td>
</tr> </tr>
<tr> <tr>
<td align="center">R50-dcn-YOLOv3 obj365_pretrain</td> <td align="center">R50-dcn-YOLOv3 obj365_pretrain</td>
...@@ -706,7 +1144,9 @@ ...@@ -706,7 +1144,9 @@
<td align="center">-</td> <td align="center">-</td>
<td align="center">150</td> <td align="center">150</td>
<td align="center">81.20</td> <td align="center">81.20</td>
<td align="center"><a href="https://paddlemodels.bj.bcebos.com/PaddleSlim/yolov3_r50vd_dcn_obj365_pretrained_coco_prune.tar">下载链接</a></td> <td align="center">-</td>
<td align="center">-</td>
<td align="center"><a href="https://paddlemodels.bj.bcebos.com/PaddleSlim/yolov3_r50vd_dcn_obj365_pretrained_coco_prune.tar">model</a></td>
</tr> </tr>
<tr> <tr>
<td align="center">R50-dcn-YOLOv3 obj365_pretrain</td> <td align="center">R50-dcn-YOLOv3 obj365_pretrain</td>
...@@ -718,25 +1158,27 @@ ...@@ -718,25 +1158,27 @@
<td align="center">-</td> <td align="center">-</td>
<td align="center">113</td> <td align="center">113</td>
<td align="center">67.48</td> <td align="center">67.48</td>
<td align="center"><a href="https://paddlemodels.bj.bcebos.com/PaddleSlim/yolov3_r50vd_dcn_obj365_pretrained_coco_prune578.tar">下载链接</a></td> <td align="center">-</td>
<td align="center">-</td>
<td align="center"><a href="https://paddlemodels.bj.bcebos.com/PaddleSlim/yolov3_r50vd_dcn_obj365_pretrained_coco_prune578.tar">model</a></td>
</tr> </tr>
</tbody> </tbody>
</table></div> </table></div>
<div class="section" id="id8"> <div class="section" id="id3">
<h3>2.3 蒸馏<a class="headerlink" href="#id8" title="Permalink to this headline"></a></h3> <h3>2.3 Distillation<a class="headerlink" href="#id3" title="Permalink to this headline"></a></h3>
<p>数据集:Pasacl VOC &amp; COCO 2017</p> <p>Dataset:Pasacl VOC &amp; COCO 2017</p>
<table border="1" class="docutils"> <table border="1" class="docutils">
<thead> <thead>
<tr> <tr>
<th align="center">模型</th> <th align="center">Model</th>
<th align="center">压缩方法</th> <th align="center">Method</th>
<th align="center">数据集</th> <th align="center">Dataset</th>
<th align="center">Image/GPU</th> <th align="center">Image/GPU</th>
<th align="center">输入608 Box AP</th> <th align="center">Input 608 Box AP</th>
<th align="center">输入416 Box AP</th> <th align="center">Input 416 Box AP</th>
<th align="center">输入320 Box AP</th> <th align="center">Input 320 Box AP</th>
<th align="center">模型体积(MB)</th> <th align="center">Model Size(MB)</th>
<th align="center">下载</th> <th align="center">Download</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
...@@ -749,7 +1191,7 @@ ...@@ -749,7 +1191,7 @@
<td align="center">76.7</td> <td align="center">76.7</td>
<td align="center">75.3</td> <td align="center">75.3</td>
<td align="center">94</td> <td align="center">94</td>
<td align="center"><a href="https://paddlemodels.bj.bcebos.com/object_detection/yolov3_mobilenet_v1_voc.tar">下载链接</a></td> <td align="center"><a href="https://paddlemodels.bj.bcebos.com/object_detection/yolov3_mobilenet_v1_voc.tar">model</a></td>
</tr> </tr>
<tr> <tr>
<td align="center">ResNet34-YOLOv3</td> <td align="center">ResNet34-YOLOv3</td>
...@@ -760,7 +1202,7 @@ ...@@ -760,7 +1202,7 @@
<td align="center">81.9</td> <td align="center">81.9</td>
<td align="center">80.1</td> <td align="center">80.1</td>
<td align="center">162</td> <td align="center">162</td>
<td align="center"><a href="https://paddlemodels.bj.bcebos.com/object_detection/yolov3_r34_voc.tar">下载链接</a></td> <td align="center"><a href="https://paddlemodels.bj.bcebos.com/object_detection/yolov3_r34_voc.tar">model</a></td>
</tr> </tr>
<tr> <tr>
<td align="center">MobileNet-V1-YOLOv3</td> <td align="center">MobileNet-V1-YOLOv3</td>
...@@ -771,7 +1213,7 @@ ...@@ -771,7 +1213,7 @@
<td align="center">78.2 (+1.5)</td> <td align="center">78.2 (+1.5)</td>
<td align="center">75.5 (+0.2)</td> <td align="center">75.5 (+0.2)</td>
<td align="center">94</td> <td align="center">94</td>
<td align="center"><a href="https://paddlemodels.bj.bcebos.com/PaddleSlim/yolov3_mobilenetv1_voc_distilled.tar">下载链接</a></td> <td align="center"><a href="https://paddlemodels.bj.bcebos.com/PaddleSlim/yolov3_mobilenetv1_voc_distilled.tar">model</a></td>
</tr> </tr>
<tr> <tr>
<td align="center">MobileNet-V1-YOLOv3</td> <td align="center">MobileNet-V1-YOLOv3</td>
...@@ -782,7 +1224,7 @@ ...@@ -782,7 +1224,7 @@
<td align="center">29.3</td> <td align="center">29.3</td>
<td align="center">27.0</td> <td align="center">27.0</td>
<td align="center">95</td> <td align="center">95</td>
<td align="center"><a href="https://paddlemodels.bj.bcebos.com/object_detection/yolov3_mobilenet_v1.tar">下载链接</a></td> <td align="center"><a href="https://paddlemodels.bj.bcebos.com/object_detection/yolov3_mobilenet_v1.tar">model</a></td>
</tr> </tr>
<tr> <tr>
<td align="center">ResNet34-YOLOv3</td> <td align="center">ResNet34-YOLOv3</td>
...@@ -793,7 +1235,7 @@ ...@@ -793,7 +1235,7 @@
<td align="center">34.3</td> <td align="center">34.3</td>
<td align="center">31.4</td> <td align="center">31.4</td>
<td align="center">163</td> <td align="center">163</td>
<td align="center"><a href="https://paddlemodels.bj.bcebos.com/object_detection/yolov3_r34.tar">下载链接</a></td> <td align="center"><a href="https://paddlemodels.bj.bcebos.com/object_detection/yolov3_r34.tar">model</a></td>
</tr> </tr>
<tr> <tr>
<td align="center">MobileNet-V1-YOLOv3</td> <td align="center">MobileNet-V1-YOLOv3</td>
...@@ -804,24 +1246,74 @@ ...@@ -804,24 +1246,74 @@
<td align="center">30.0 (+0.7)</td> <td align="center">30.0 (+0.7)</td>
<td align="center">27.1 (+0.1)</td> <td align="center">27.1 (+0.1)</td>
<td align="center">95</td> <td align="center">95</td>
<td align="center"><a href="https://paddlemodels.bj.bcebos.com/PaddleSlim/yolov3_mobilenetv1_coco_distilled.tar">下载链接</a></td> <td align="center"><a href="https://paddlemodels.bj.bcebos.com/PaddleSlim/yolov3_mobilenetv1_coco_distilled.tar">model</a></td>
</tr> </tr>
</tbody> </tbody>
</table></div> </table></div>
<div class="section" id="id4">
<h3>2.4 NAS<a class="headerlink" href="#id4" title="Permalink to this headline"></a></h3>
<p>Dataset: WIDER-FACE</p>
<table border="1" class="docutils">
<thead>
<tr>
<th align="center">Model</th>
<th align="center">Method</th>
<th align="center">Image/GPU</th>
<th align="center">Input size</th>
<th align="center">Easy/Medium/Hard</th>
<th align="center">volume(KB)</th>
<th align="center">latency(ms)</th>
<th align="center">Download</th>
</tr>
</thead>
<tbody>
<tr>
<td align="center">BlazeFace</td>
<td align="center">-</td>
<td align="center">8</td>
<td align="center">640</td>
<td align="center">91.5/89.2/79.7</td>
<td align="center">815</td>
<td align="center">71.862</td>
<td align="center"><a href="https://paddlemodels.bj.bcebos.com/object_detection/blazeface_original.tar">model</a></td>
</tr>
<tr>
<td align="center">BlazeFace-NAS</td>
<td align="center">-</td>
<td align="center">8</td>
<td align="center">640</td>
<td align="center">83.7/80.7/65.8</td>
<td align="center">244</td>
<td align="center">21.117</td>
<td align="center"><a href="https://paddlemodels.bj.bcebos.com/object_detection/blazeface_nas.tar">model</a></td>
</tr>
<tr>
<td align="center">BlazeFace-NASV2</td>
<td align="center">SANAS</td>
<td align="center">8</td>
<td align="center">640</td>
<td align="center">87.0/83.7/68.5</td>
<td align="center">389</td>
<td align="center">22.558</td>
<td align="center"><a href="https://paddlemodels.bj.bcebos.com/object_detection/blazeface_nas2.tar">model</a></td>
</tr>
</tbody>
</table><p>Note: latency is based on latency_855.txt, the file is test on 855 by PaddleLite。The config of BlazeFace-NASV2 is in <a class="reference external" href="https://github.com/PaddlePaddle/PaddleDetection/blob/master/configs/face_detection/blazeface_nas_v2.yml">there</a>.</p>
</div> </div>
<div class="section" id="id9"> </div>
<h2>3. 图像分割<a class="headerlink" href="#id9" title="Permalink to this headline"></a></h2> <div class="section" id="image-segmentation">
<p>数据集:Cityscapes</p> <h2>3. Image Segmentation<a class="headerlink" href="#image-segmentation" title="Permalink to this headline"></a></h2>
<div class="section" id="id10"> <p>Dataset:Cityscapes</p>
<h3>3.1 量化<a class="headerlink" href="#id10" title="Permalink to this headline"></a></h3> <div class="section" id="id5">
<h3>3.1 Quantization<a class="headerlink" href="#id5" title="Permalink to this headline"></a></h3>
<table border="1" class="docutils"> <table border="1" class="docutils">
<thead> <thead>
<tr> <tr>
<th align="center">模型</th> <th align="center">Model</th>
<th align="center">压缩方法</th> <th align="center">Method</th>
<th align="center">mIoU</th> <th align="center">mIoU</th>
<th align="center">模型体积(MB)</th> <th align="center">Model Size(MB)</th>
<th align="center">下载</th> <th align="center">Download</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
...@@ -829,57 +1321,278 @@ ...@@ -829,57 +1321,278 @@
<td align="center">DeepLabv3+/MobileNetv1</td> <td align="center">DeepLabv3+/MobileNetv1</td>
<td align="center">-</td> <td align="center">-</td>
<td align="center">63.26</td> <td align="center">63.26</td>
<td align="center">xx</td> <td align="center">6.6</td>
<td align="center"><a href="">下载链接</a></td> <td align="center"><a href="https://paddlemodels.bj.bcebos.com/PaddleSlim/deeplabv3_mobilenetv1.tar">model</a></td>
</tr> </tr>
<tr> <tr>
<td align="center">DeepLabv3+/MobileNetv1</td> <td align="center">DeepLabv3+/MobileNetv1</td>
<td align="center">quant_post</td> <td align="center">quant_post</td>
<td align="center">xx</td> <td align="center">58.63 (-4.63)</td>
<td align="center">xx</td> <td align="center">1.8</td>
<td align="center"><a href="">下载链接</a></td> <td align="center"><a href="https://paddlemodels.bj.bcebos.com/PaddleSlim/deeplabv3_mobilenetv1_2049x1025_quant_post.tar">model</a></td>
</tr> </tr>
<tr> <tr>
<td align="center">DeepLabv3+/MobileNetv1</td> <td align="center">DeepLabv3+/MobileNetv1</td>
<td align="center">quant_aware</td> <td align="center">quant_aware</td>
<td align="center">xx</td> <td align="center">62.03 (-1.23)</td>
<td align="center">xx</td> <td align="center">1.8</td>
<td align="center"><a href="">下载链接</a></td> <td align="center"><a href="https://paddlemodels.bj.bcebos.com/PaddleSlim/deeplabv3_mobilenetv1_2049x1025_quant_aware.tar">model</a></td>
</tr> </tr>
<tr> <tr>
<td align="center">DeepLabv3+/MobileNetv2</td> <td align="center">DeepLabv3+/MobileNetv2</td>
<td align="center">-</td> <td align="center">-</td>
<td align="center">69.81</td> <td align="center">69.81</td>
<td align="center">xx</td> <td align="center">7.4</td>
<td align="center"><a href="">下载链接</a></td> <td align="center"><a href="https://paddleseg.bj.bcebos.com/models/mobilenet_cityscapes.tgz">model</a></td>
</tr> </tr>
<tr> <tr>
<td align="center">DeepLabv3+/MobileNetv2</td> <td align="center">DeepLabv3+/MobileNetv2</td>
<td align="center">quant_post</td> <td align="center">quant_post</td>
<td align="center">xx</td> <td align="center">67.59 (-2.22)</td>
<td align="center">xx</td> <td align="center">2.1</td>
<td align="center"><a href="">下载链接</a></td> <td align="center"><a href="https://paddlemodels.bj.bcebos.com/PaddleSlim/deeplabv3_mobilenetv2_2049x1025_quant_post.tar">model</a></td>
</tr> </tr>
<tr> <tr>
<td align="center">DeepLabv3+/MobileNetv2</td> <td align="center">DeepLabv3+/MobileNetv2</td>
<td align="center">quant_aware</td> <td align="center">quant_aware</td>
<td align="center">xx</td> <td align="center">68.33 (-1.48)</td>
<td align="center">xx</td> <td align="center">2.1</td>
<td align="center"><a href="">下载链接</a></td> <td align="center"><a href="https://paddlemodels.bj.bcebos.com/PaddleSlim/deeplabv3_mobilenetv2_2049x1025_quant_aware.tar">model</a></td>
</tr>
</tbody>
</table><p>Image segmentation model PaddleLite latency (ms), input size 769x769</p>
<table border="1" class="docutils">
<thead>
<tr>
<th>Device</th>
<th>Model</th>
<th>Method</th>
<th>armv7 Thread 1</th>
<th>armv7 Thread 2</th>
<th>armv7 Thread 4</th>
<th>armv8 Thread 1</th>
<th>armv8 Thread 2</th>
<th>armv8 Thread 4</th>
</tr>
</thead>
<tbody>
<tr>
<td>Qualcomm 835</td>
<td>Deeplabv3- MobileNetV1</td>
<td>FP32 baseline</td>
<td>1227.9894</td>
<td>734.1922</td>
<td>527.9592</td>
<td>1109.96</td>
<td>699.3818</td>
<td>479.0818</td>
</tr>
<tr>
<td>Qualcomm 835</td>
<td>Deeplabv3- MobileNetV1</td>
<td>quant_aware</td>
<td>848.6544</td>
<td>512.785</td>
<td>382.9915</td>
<td>752.3573</td>
<td>455.0901</td>
<td>307.8808</td>
</tr>
<tr>
<td>Qualcomm 835</td>
<td>Deeplabv3- MobileNetV1</td>
<td>quant_post</td>
<td>840.2323</td>
<td>510.103</td>
<td>371.9315</td>
<td>748.9401</td>
<td>452.1745</td>
<td>309.2084</td>
</tr>
<tr>
<td>Qualcomm 835</td>
<td>Deeplabv3-MobileNetV2</td>
<td>FP32 baseline</td>
<td>1282.8126</td>
<td>793.2064</td>
<td>653.6538</td>
<td>1193.9908</td>
<td>737.1827</td>
<td>593.4522</td>
</tr>
<tr>
<td>Qualcomm 835</td>
<td>Deeplabv3-MobileNetV2</td>
<td>quant_aware</td>
<td>976.0495</td>
<td>659.0541</td>
<td>513.4279</td>
<td>892.1468</td>
<td>582.9847</td>
<td>484.7512</td>
</tr>
<tr>
<td>Qualcomm 835</td>
<td>Deeplabv3-MobileNetV2</td>
<td>quant_post</td>
<td>981.44</td>
<td>658.4969</td>
<td>538.6166</td>
<td>885.3273</td>
<td>586.1284</td>
<td>484.0018</td>
</tr>
<tr>
<td>Qualcomm 855</td>
<td>Deeplabv3- MobileNetV1</td>
<td>FP32 baseline</td>
<td>568.8748</td>
<td>339.8578</td>
<td>278.6316</td>
<td>420.6031</td>
<td>281.3197</td>
<td>217.5222</td>
</tr>
<tr>
<td>Qualcomm 855</td>
<td>Deeplabv3- MobileNetV1</td>
<td>quant_aware</td>
<td>608.7578</td>
<td>347.2087</td>
<td>260.653</td>
<td>241.2394</td>
<td>177.3456</td>
<td>143.9178</td>
</tr>
<tr>
<td>Qualcomm 855</td>
<td>Deeplabv3- MobileNetV1</td>
<td>quant_post</td>
<td>609.0142</td>
<td>347.3784</td>
<td>259.9825</td>
<td>239.4103</td>
<td>180.1894</td>
<td>139.9178</td>
</tr>
<tr>
<td>Qualcomm 855</td>
<td>Deeplabv3-MobileNetV2</td>
<td>FP32 baseline</td>
<td>639.4425</td>
<td>390.1851</td>
<td>322.7014</td>
<td>477.7667</td>
<td>339.7411</td>
<td>262.2847</td>
</tr>
<tr>
<td>Qualcomm 855</td>
<td>Deeplabv3-MobileNetV2</td>
<td>quant_aware</td>
<td>703.7275</td>
<td>497.689</td>
<td>417.1296</td>
<td>394.3586</td>
<td>300.2503</td>
<td>239.9204</td>
</tr>
<tr>
<td>Qualcomm 855</td>
<td>Deeplabv3-MobileNetV2</td>
<td>quant_post</td>
<td>705.7589</td>
<td>474.4076</td>
<td>427.2951</td>
<td>394.8352</td>
<td>297.4035</td>
<td>264.6724</td>
</tr>
<tr>
<td>Kirin 970</td>
<td>Deeplabv3- MobileNetV1</td>
<td>FP32 baseline</td>
<td>1682.1792</td>
<td>1437.9774</td>
<td>1181.0246</td>
<td>1261.6739</td>
<td>1068.6537</td>
<td>690.8225</td>
</tr>
<tr>
<td>Kirin 970</td>
<td>Deeplabv3- MobileNetV1</td>
<td>quant_aware</td>
<td>1062.3394</td>
<td>1248.1014</td>
<td>878.3157</td>
<td>774.6356</td>
<td>710.6277</td>
<td>528.5376</td>
</tr>
<tr>
<td>Kirin 970</td>
<td>Deeplabv3- MobileNetV1</td>
<td>quant_post</td>
<td>1109.1917</td>
<td>1339.6218</td>
<td>866.3587</td>
<td>771.5164</td>
<td>716.5255</td>
<td>500.6497</td>
</tr>
<tr>
<td>Kirin 970</td>
<td>Deeplabv3-MobileNetV2</td>
<td>FP32 baseline</td>
<td>1771.1301</td>
<td>1746.0569</td>
<td>1222.4805</td>
<td>1448.9739</td>
<td>1192.4491</td>
<td>760.606</td>
</tr>
<tr>
<td>Kirin 970</td>
<td>Deeplabv3-MobileNetV2</td>
<td>quant_aware</td>
<td>1320.2905</td>
<td>921.4522</td>
<td>676.0732</td>
<td>1145.8801</td>
<td>821.5685</td>
<td>590.1713</td>
</tr>
<tr>
<td>Kirin 970</td>
<td>Deeplabv3-MobileNetV2</td>
<td>quant_post</td>
<td>1320.386</td>
<td>918.5328</td>
<td>672.2481</td>
<td>1020.753</td>
<td>820.094</td>
<td>591.4114</td>
</tr> </tr>
</tbody> </tbody>
</table></div> </table></div>
<div class="section" id="id11"> <div class="section" id="id6">
<h3>3.2 剪裁<a class="headerlink" href="#id11" title="Permalink to this headline"></a></h3> <h3>3.2 Pruning<a class="headerlink" href="#id6" title="Permalink to this headline"></a></h3>
<p>PaddleLite:</p>
<p>env: Qualcomm SnapDragon 845 + armv8</p>
<p>criterion: time cost in Thread1/Thread2/Thread4</p>
<p>PaddleLite version: v2.3</p>
<table border="1" class="docutils"> <table border="1" class="docutils">
<thead> <thead>
<tr> <tr>
<th align="center">模型</th> <th align="center">Model</th>
<th align="center">压缩方法</th> <th align="center">Method</th>
<th align="center">mIoU</th> <th align="center">mIoU</th>
<th align="center">模型体积(MB)</th> <th align="center">Model Size(MB)</th>
<th align="center">GFLOPs</th> <th align="center">GFLOPs</th>
<th align="center">下载</th> <th align="center">PaddleLite cost(ms)</th>
<th align="center">TensorRT speed(FPS)</th>
<th align="center">Download</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
...@@ -889,7 +1602,9 @@ ...@@ -889,7 +1602,9 @@
<td align="center">69.64</td> <td align="center">69.64</td>
<td align="center">11</td> <td align="center">11</td>
<td align="center">14.41</td> <td align="center">14.41</td>
<td align="center"><a href="https://paddlemodels.bj.bcebos.com/PaddleSlim/fast_scnn_cityscape.tar">下载链接</a></td> <td align="center">1226.36\682.96\415.664</td>
<td align="center">39.53</td>
<td align="center"><a href="https://paddlemodels.bj.bcebos.com/PaddleSlim/fast_scnn_cityscape.tar">model</a></td>
</tr> </tr>
<tr> <tr>
<td align="center">fast-scnn</td> <td align="center">fast-scnn</td>
...@@ -897,7 +1612,9 @@ ...@@ -897,7 +1612,9 @@
<td align="center">69.58 (-0.06)</td> <td align="center">69.58 (-0.06)</td>
<td align="center">8.5</td> <td align="center">8.5</td>
<td align="center">11.95</td> <td align="center">11.95</td>
<td align="center"><a href="https://paddlemodels.bj.bcebos.com/PaddleSlim/fast_scnn_cityscape_uniform-17.tar">下载链接</a></td> <td align="center">1140.37\656.612\415.888</td>
<td align="center">42.01</td>
<td align="center"><a href="https://paddlemodels.bj.bcebos.com/PaddleSlim/fast_scnn_cityscape_uniform-17.tar">model</a></td>
</tr> </tr>
<tr> <tr>
<td align="center">fast-scnn</td> <td align="center">fast-scnn</td>
...@@ -905,7 +1622,9 @@ ...@@ -905,7 +1622,9 @@
<td align="center">66.68 (-2.96)</td> <td align="center">66.68 (-2.96)</td>
<td align="center">5.7</td> <td align="center">5.7</td>
<td align="center">7.55</td> <td align="center">7.55</td>
<td align="center"><a href="https://paddlemodels.bj.bcebos.com/PaddleSlim/fast_scnn_cityscape_sensitive-47.tar">下载链接</a></td> <td align="center">866.693\494.467\291.748</td>
<td align="center">51.48</td>
<td align="center"><a href="https://paddlemodels.bj.bcebos.com/PaddleSlim/fast_scnn_cityscape_sensitive-47.tar">model</a></td>
</tr> </tr>
</tbody> </tbody>
</table></div> </table></div>
...@@ -920,7 +1639,7 @@ ...@@ -920,7 +1639,7 @@
<div class="rst-footer-buttons" role="navigation" aria-label="footer navigation"> <div class="rst-footer-buttons" role="navigation" aria-label="footer navigation">
<a href="api_en/search_space_en.html" class="btn btn-neutral" title="search space" accesskey="p"><span class="fa fa-arrow-circle-left"></span> Previous</a> <a href="api_en/table_latency_en.html" class="btn btn-neutral" title="Table about hardware lantency" accesskey="p"><span class="fa fa-arrow-circle-left"></span> Previous</a>
</div> </div>
......
无法预览此类型文件
...@@ -83,7 +83,7 @@ ...@@ -83,7 +83,7 @@
<ul class="current"> <ul class="current">
<li class="toctree-l1"><a class="reference internal" href="../index_en.html">English Documents</a></li> <li class="toctree-l1"><a class="reference internal" href="../index_en.html">English Documents</a></li>
<li class="toctree-l1"><a class="reference internal" href="../intro.html">PaddleSlim简介</a></li> <li class="toctree-l1"><a class="reference internal" href="../intro.html">介绍</a></li>
<li class="toctree-l1"><a class="reference internal" href="../install.html">安装</a></li> <li class="toctree-l1"><a class="reference internal" href="../install.html">安装</a></li>
<li class="toctree-l1 current"><a class="reference internal" href="index.html">快速开始</a><ul class="current"> <li class="toctree-l1 current"><a class="reference internal" href="index.html">快速开始</a><ul class="current">
<li class="toctree-l2"><a class="reference internal" href="pruning_tutorial.html">图像分类模型通道剪裁-快速开始</a></li> <li class="toctree-l2"><a class="reference internal" href="pruning_tutorial.html">图像分类模型通道剪裁-快速开始</a></li>
...@@ -154,7 +154,7 @@ ...@@ -154,7 +154,7 @@
<h1>图像分类模型知识蒸馏-快速开始<a class="headerlink" href="#id1" title="永久链接至标题"></a></h1> <h1>图像分类模型知识蒸馏-快速开始<a class="headerlink" href="#id1" title="永久链接至标题"></a></h1>
<p>该教程以图像分类模型MobileNetV1为例,说明如何快速使用<a class="reference external" href="https://paddlepaddle.github.io/PaddleSlim/api/single_distiller_api/">PaddleSlim的知识蒸馏接口</a> <p>该教程以图像分类模型MobileNetV1为例,说明如何快速使用<a class="reference external" href="https://paddlepaddle.github.io/PaddleSlim/api/single_distiller_api/">PaddleSlim的知识蒸馏接口</a>
该示例包含以下步骤:</p> 该示例包含以下步骤:</p>
<ol class="simple"> <ol class="arabic simple">
<li>导入依赖</li> <li>导入依赖</li>
<li>定义student_program和teacher_program</li> <li>定义student_program和teacher_program</li>
<li>选择特征图</li> <li>选择特征图</li>
...@@ -165,9 +165,9 @@ ...@@ -165,9 +165,9 @@
<div class="section" id="id2"> <div class="section" id="id2">
<h2>1. 导入依赖<a class="headerlink" href="#id2" title="永久链接至标题"></a></h2> <h2>1. 导入依赖<a class="headerlink" href="#id2" title="永久链接至标题"></a></h2>
<p>PaddleSlim依赖Paddle1.7版本,请确认已正确安装Paddle,然后按以下方式导入Paddle和PaddleSlim:</p> <p>PaddleSlim依赖Paddle1.7版本,请确认已正确安装Paddle,然后按以下方式导入Paddle和PaddleSlim:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">paddle</span> <div class="highlight-guess"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">paddle</span>
<span class="kn">import</span> <span class="nn">paddle.fluid</span> <span class="k">as</span> <span class="nn">fluid</span> <span class="kn">import</span> <span class="nn">paddle.fluid</span> <span class="kn">as</span> <span class="nn">fluid</span>
<span class="kn">import</span> <span class="nn">paddleslim</span> <span class="k">as</span> <span class="nn">slim</span> <span class="kn">import</span> <span class="nn">paddleslim</span> <span class="kn">as</span> <span class="nn">slim</span>
</pre></div> </pre></div>
</div> </div>
</div> </div>
...@@ -222,11 +222,11 @@ ...@@ -222,11 +222,11 @@
<span class="c1">#print(teacher_vars)</span> <span class="c1">#print(teacher_vars)</span>
</pre></div> </pre></div>
</div> </div>
<p>经过筛选我们可以看到,teacher_program中的&#8216;bn5c_branch2b.output.1.tmp_3&#8216;和student_program的&#8216;depthwise_conv2d_11.tmp_0&#8216;尺寸一致,可以组成蒸馏损失函数。</p> <p>经过筛选我们可以看到,teacher_program中的&#8217;bn5c_branch2b.output.1.tmp_3&#8217;和student_program的&#8217;depthwise_conv2d_11.tmp_0&#8217;尺寸一致,可以组成蒸馏损失函数。</p>
</div> </div>
<div class="section" id="program-merge-loss"> <div class="section" id="program-merge-loss">
<h2>4. 合并program (merge)并添加蒸馏loss<a class="headerlink" href="#program-merge-loss" title="永久链接至标题"></a></h2> <h2>4. 合并program (merge)并添加蒸馏loss<a class="headerlink" href="#program-merge-loss" title="永久链接至标题"></a></h2>
<p>merge操作将student_program和teacher_program中的所有Variables和Op都将被添加到同一个Program中,同时为了避免两个program中有同名变量会引起命名冲突,merge也会为teacher_program中的Variables添加一个同一的命名前缀name_prefix,其默认值是&#8216;teacher_&#8216;</p> <p>merge操作将student_program和teacher_program中的所有Variables和Op都将被添加到同一个Program中,同时为了避免两个program中有同名变量会引起命名冲突,merge也会为teacher_program中的Variables添加一个同一的命名前缀name<em>prefix,其默认值是&#8217;teacher</em>&#8216;</p>
<p>为了确保teacher网络和student网络输入的数据是一样的,merge操作也会对两个program的输入数据层进行合并操作,所以需要指定一个数据层名称的映射关系data_name_map,key是teacher的输入数据名称,value是student的</p> <p>为了确保teacher网络和student网络输入的数据是一样的,merge操作也会对两个program的输入数据层进行合并操作,所以需要指定一个数据层名称的映射关系data_name_map,key是teacher的输入数据名称,value是student的</p>
<div class="highlight-python"><div class="highlight"><pre><span></span><span class="n">data_name_map</span> <span class="o">=</span> <span class="p">{</span><span class="s1">&#39;image&#39;</span><span class="p">:</span> <span class="s1">&#39;image&#39;</span><span class="p">}</span> <div class="highlight-python"><div class="highlight"><pre><span></span><span class="n">data_name_map</span> <span class="o">=</span> <span class="p">{</span><span class="s1">&#39;image&#39;</span><span class="p">:</span> <span class="s1">&#39;image&#39;</span><span class="p">}</span>
<span class="n">main</span> <span class="o">=</span> <span class="n">slim</span><span class="o">.</span><span class="n">dist</span><span class="o">.</span><span class="n">merge</span><span class="p">(</span><span class="n">teacher_program</span><span class="p">,</span> <span class="n">student_program</span><span class="p">,</span> <span class="n">data_name_map</span><span class="p">,</span> <span class="n">fluid</span><span class="o">.</span><span class="n">CPUPlace</span><span class="p">())</span> <span class="n">main</span> <span class="o">=</span> <span class="n">slim</span><span class="o">.</span><span class="n">dist</span><span class="o">.</span><span class="n">merge</span><span class="p">(</span><span class="n">teacher_program</span><span class="p">,</span> <span class="n">student_program</span><span class="p">,</span> <span class="n">data_name_map</span><span class="p">,</span> <span class="n">fluid</span><span class="o">.</span><span class="n">CPUPlace</span><span class="p">())</span>
......
...@@ -134,7 +134,7 @@ ...@@ -134,7 +134,7 @@
<h1>Knowledge Distillation for Image Classification<a class="headerlink" href="#knowledge-distillation-for-image-classification" title="Permalink to this headline"></a></h1> <h1>Knowledge Distillation for Image Classification<a class="headerlink" href="#knowledge-distillation-for-image-classification" title="Permalink to this headline"></a></h1>
<p>In this tutorial, you will learn how to use knowledge distillation API of PaddleSlim <p>In this tutorial, you will learn how to use knowledge distillation API of PaddleSlim
by a demo of MobileNetV1 model on MNIST dataset. This tutorial following workflow:</p> by a demo of MobileNetV1 model on MNIST dataset. This tutorial following workflow:</p>
<ol class="simple"> <ol class="arabic simple">
<li>Import dependency</li> <li>Import dependency</li>
<li>Define student_program and teacher_program</li> <li>Define student_program and teacher_program</li>
<li>Select feature maps</li> <li>Select feature maps</li>
...@@ -144,16 +144,16 @@ by a demo of MobileNetV1 model on MNIST dataset. This tutorial following workflo ...@@ -144,16 +144,16 @@ by a demo of MobileNetV1 model on MNIST dataset. This tutorial following workflo
<div class="section" id="import-dependency"> <div class="section" id="import-dependency">
<h2>1. Import dependency<a class="headerlink" href="#import-dependency" title="Permalink to this headline"></a></h2> <h2>1. Import dependency<a class="headerlink" href="#import-dependency" title="Permalink to this headline"></a></h2>
<p>PaddleSlim dependents on Paddle1.7. Please ensure that you have installed paddle correctly. Import Paddle and PaddleSlim as below:</p> <p>PaddleSlim dependents on Paddle1.7. Please ensure that you have installed paddle correctly. Import Paddle and PaddleSlim as below:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">paddle</span> <div class="highlight-guess"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">paddle</span>
<span class="kn">import</span> <span class="nn">paddle.fluid</span> <span class="k">as</span> <span class="nn">fluid</span> <span class="kn">import</span> <span class="nn">paddle.fluid</span> <span class="kn">as</span> <span class="nn">fluid</span>
<span class="kn">import</span> <span class="nn">paddleslim</span> <span class="k">as</span> <span class="nn">slim</span> <span class="kn">import</span> <span class="nn">paddleslim</span> <span class="kn">as</span> <span class="nn">slim</span>
</pre></div> </pre></div>
</div> </div>
</div> </div>
<div class="section" id="define-student-program-and-teacher-program"> <div class="section" id="define-student-program-and-teacher-program">
<h2>2. Define student_program and teacher_program<a class="headerlink" href="#define-student-program-and-teacher-program" title="Permalink to this headline"></a></h2> <h2>2. Define student_program and teacher_program<a class="headerlink" href="#define-student-program-and-teacher-program" title="Permalink to this headline"></a></h2>
<p>This tutorial trains and verifies distillation model on the MNIST dataset. The input image shape is <code class="docutils literal"><span class="pre">[1,</span> <span class="pre">28,</span> <span class="pre">28]</span> </code>and the number of output categories is 10. <p>This tutorial trains and verifies distillation model on the MNIST dataset. The input image shape is <code class="docutils literal"><span class="pre">[1,</span> <span class="pre">28,</span> <span class="pre">28]</span></code>and the number of output categories is 10.
Select <code class="docutils literal"><span class="pre">ResNet50</span></code> as the teacher to perform distillation training on the students of the<code class="docutils literal"> <span class="pre">MobileNet</span></code> architecture.</p> Select <code class="docutils literal"><span class="pre">ResNet50</span></code> as the teacher to perform distillation training on the students of the<code class="docutils literal"><span class="pre">MobileNet</span></code> architecture.</p>
<div class="highlight-python"><div class="highlight"><pre><span></span><span class="n">model</span> <span class="o">=</span> <span class="n">models</span><span class="o">.</span><span class="vm">__dict__</span><span class="p">[</span><span class="s1">&#39;MobileNet&#39;</span><span class="p">]()</span> <div class="highlight-python"><div class="highlight"><pre><span></span><span class="n">model</span> <span class="o">=</span> <span class="n">models</span><span class="o">.</span><span class="vm">__dict__</span><span class="p">[</span><span class="s1">&#39;MobileNet&#39;</span><span class="p">]()</span>
<span class="n">student_program</span> <span class="o">=</span> <span class="n">fluid</span><span class="o">.</span><span class="n">Program</span><span class="p">()</span> <span class="n">student_program</span> <span class="o">=</span> <span class="n">fluid</span><span class="o">.</span><span class="n">Program</span><span class="p">()</span>
<span class="n">student_startup</span> <span class="o">=</span> <span class="n">fluid</span><span class="o">.</span><span class="n">Program</span><span class="p">()</span> <span class="n">student_startup</span> <span class="o">=</span> <span class="n">fluid</span><span class="o">.</span><span class="n">Program</span><span class="p">()</span>
...@@ -183,7 +183,7 @@ Select <code class="docutils literal"><span class="pre">ResNet50</span></code> a ...@@ -183,7 +183,7 @@ Select <code class="docutils literal"><span class="pre">ResNet50</span></code> a
</div> </div>
<div class="section" id="select-feature-maps"> <div class="section" id="select-feature-maps">
<h2>3. Select feature maps<a class="headerlink" href="#select-feature-maps" title="Permalink to this headline"></a></h2> <h2>3. Select feature maps<a class="headerlink" href="#select-feature-maps" title="Permalink to this headline"></a></h2>
<p>We can use the student_program&#8216;s list_vars method to observe all the Variables, and select one or more variables from it to fit the corresponding variables of the teacher.</p> <p>We can use the student_program&#8217;s list_vars method to observe all the Variables, and select one or more variables from it to fit the corresponding variables of the teacher.</p>
<div class="highlight-python"><div class="highlight"><pre><span></span><span class="c1"># get all student variables</span> <div class="highlight-python"><div class="highlight"><pre><span></span><span class="c1"># get all student variables</span>
<span class="n">student_vars</span> <span class="o">=</span> <span class="p">[]</span> <span class="n">student_vars</span> <span class="o">=</span> <span class="p">[]</span>
<span class="k">for</span> <span class="n">v</span> <span class="ow">in</span> <span class="n">student_program</span><span class="o">.</span><span class="n">list_vars</span><span class="p">():</span> <span class="k">for</span> <span class="n">v</span> <span class="ow">in</span> <span class="n">student_program</span><span class="o">.</span><span class="n">list_vars</span><span class="p">():</span>
...@@ -201,12 +201,12 @@ Select <code class="docutils literal"><span class="pre">ResNet50</span></code> a ...@@ -201,12 +201,12 @@ Select <code class="docutils literal"><span class="pre">ResNet50</span></code> a
<span class="c1">#print(teacher_vars)</span> <span class="c1">#print(teacher_vars)</span>
</pre></div> </pre></div>
</div> </div>
<p>we can see that the shape of &#8216;bn5c_branch2b.output.1.tmp_3&#8216; in the teacher_program and the &#8216;depthwise_conv2d_11.tmp_0&#8216; of the student are the same and can form the distillation loss function.</p> <p>we can see that the shape of &#8216;bn5c_branch2b.output.1.tmp_3&#8217; in the teacher_program and the &#8216;depthwise_conv2d_11.tmp_0&#8217; of the student are the same and can form the distillation loss function.</p>
</div> </div>
<div class="section" id="merge-program-and-add-distillation-loss"> <div class="section" id="merge-program-and-add-distillation-loss">
<h2>4. Merge program and add distillation loss<a class="headerlink" href="#merge-program-and-add-distillation-loss" title="Permalink to this headline"></a></h2> <h2>4. Merge program and add distillation loss<a class="headerlink" href="#merge-program-and-add-distillation-loss" title="Permalink to this headline"></a></h2>
<p>The merge operation adds all Variables and Ops in teacher_program to student_Program. At the same time, in order to avoid naming conflicts caused by variables with the same name in two programs, merge will also add a unified naming prefix <strong>name_prefix</strong> for Variables in teacher_program, which The default value is &#8216;teacher_&#8216;_.</p> <p>The merge operation adds all Variables and Ops in teacher_program to student_Program. At the same time, in order to avoid naming conflicts caused by variables with the same name in two programs, merge will also add a unified naming prefix <strong>name_prefix</strong> for Variables in teacher<em>program, which The default value is &#8216;teacher</em>&#8216;_.</p>
<p>In order to ensure that the data of the teacher network and the student network are the same, the merge operation also merges the input data layers of the two programs, so you need to specify a data layer name mapping <em><strong>data_name_map</strong></em>, where key is the input data name of the teacher, and value Is student&#8216;s.</p> <p>In order to ensure that the data of the teacher network and the student network are the same, the merge operation also merges the input data layers of the two programs, so you need to specify a data layer name mapping <a href="#id1"><span class="problematic" id="id2">**</span></a><em>data_name_map</em><a href="#id3"><span class="problematic" id="id4">**</span></a>, where key is the input data name of the teacher, and value Is student&#8217;s.</p>
<div class="highlight-python"><div class="highlight"><pre><span></span><span class="n">data_name_map</span> <span class="o">=</span> <span class="p">{</span><span class="s1">&#39;image&#39;</span><span class="p">:</span> <span class="s1">&#39;image&#39;</span><span class="p">}</span> <div class="highlight-python"><div class="highlight"><pre><span></span><span class="n">data_name_map</span> <span class="o">=</span> <span class="p">{</span><span class="s1">&#39;image&#39;</span><span class="p">:</span> <span class="s1">&#39;image&#39;</span><span class="p">}</span>
<span class="n">main</span> <span class="o">=</span> <span class="n">slim</span><span class="o">.</span><span class="n">dist</span><span class="o">.</span><span class="n">merge</span><span class="p">(</span><span class="n">teacher_program</span><span class="p">,</span> <span class="n">student_program</span><span class="p">,</span> <span class="n">data_name_map</span><span class="p">,</span> <span class="n">fluid</span><span class="o">.</span><span class="n">CPUPlace</span><span class="p">())</span> <span class="n">main</span> <span class="o">=</span> <span class="n">slim</span><span class="o">.</span><span class="n">dist</span><span class="o">.</span><span class="n">merge</span><span class="p">(</span><span class="n">teacher_program</span><span class="p">,</span> <span class="n">student_program</span><span class="p">,</span> <span class="n">data_name_map</span><span class="p">,</span> <span class="n">fluid</span><span class="o">.</span><span class="n">CPUPlace</span><span class="p">())</span>
<span class="k">with</span> <span class="n">fluid</span><span class="o">.</span><span class="n">program_guard</span><span class="p">(</span><span class="n">student_program</span><span class="p">,</span> <span class="n">student_startup</span><span class="p">):</span> <span class="k">with</span> <span class="n">fluid</span><span class="o">.</span><span class="n">program_guard</span><span class="p">(</span><span class="n">student_program</span><span class="p">,</span> <span class="n">student_startup</span><span class="p">):</span>
......
...@@ -82,7 +82,7 @@ ...@@ -82,7 +82,7 @@
<ul class="current"> <ul class="current">
<li class="toctree-l1"><a class="reference internal" href="../index_en.html">English Documents</a></li> <li class="toctree-l1"><a class="reference internal" href="../index_en.html">English Documents</a></li>
<li class="toctree-l1"><a class="reference internal" href="../intro.html">PaddleSlim简介</a></li> <li class="toctree-l1"><a class="reference internal" href="../intro.html">介绍</a></li>
<li class="toctree-l1"><a class="reference internal" href="../install.html">安装</a></li> <li class="toctree-l1"><a class="reference internal" href="../install.html">安装</a></li>
<li class="toctree-l1 current"><a class="current reference internal" href="#">快速开始</a><ul> <li class="toctree-l1 current"><a class="current reference internal" href="#">快速开始</a><ul>
<li class="toctree-l2"><a class="reference internal" href="pruning_tutorial.html">图像分类模型通道剪裁-快速开始</a></li> <li class="toctree-l2"><a class="reference internal" href="pruning_tutorial.html">图像分类模型通道剪裁-快速开始</a></li>
......
...@@ -83,7 +83,7 @@ ...@@ -83,7 +83,7 @@
<ul class="current"> <ul class="current">
<li class="toctree-l1"><a class="reference internal" href="../index_en.html">English Documents</a></li> <li class="toctree-l1"><a class="reference internal" href="../index_en.html">English Documents</a></li>
<li class="toctree-l1"><a class="reference internal" href="../intro.html">PaddleSlim简介</a></li> <li class="toctree-l1"><a class="reference internal" href="../intro.html">介绍</a></li>
<li class="toctree-l1"><a class="reference internal" href="../install.html">安装</a></li> <li class="toctree-l1"><a class="reference internal" href="../install.html">安装</a></li>
<li class="toctree-l1 current"><a class="reference internal" href="index.html">快速开始</a><ul class="current"> <li class="toctree-l1 current"><a class="reference internal" href="index.html">快速开始</a><ul class="current">
<li class="toctree-l2"><a class="reference internal" href="pruning_tutorial.html">图像分类模型通道剪裁-快速开始</a></li> <li class="toctree-l2"><a class="reference internal" href="pruning_tutorial.html">图像分类模型通道剪裁-快速开始</a></li>
...@@ -91,22 +91,22 @@ ...@@ -91,22 +91,22 @@
<li class="toctree-l2"><a class="reference internal" href="quant_aware_tutorial.html">图像分类模型量化训练-快速开始</a></li> <li class="toctree-l2"><a class="reference internal" href="quant_aware_tutorial.html">图像分类模型量化训练-快速开始</a></li>
<li class="toctree-l2"><a class="reference internal" href="quant_post_tutorial.html">图像分类模型离线量化-快速开始</a></li> <li class="toctree-l2"><a class="reference internal" href="quant_post_tutorial.html">图像分类模型离线量化-快速开始</a></li>
<li class="toctree-l2 current"><a class="current reference internal" href="#">图像分类网络结构搜索-快速开始</a><ul> <li class="toctree-l2 current"><a class="current reference internal" href="#">图像分类网络结构搜索-快速开始</a><ul>
<li class="toctree-l3"><a class="reference internal" href="#id2">1. 导入依赖</a></li> <li class="toctree-l3"><a class="reference internal" href="#id3">1. 导入依赖</a></li>
<li class="toctree-l3"><a class="reference internal" href="#sanas">2. 初始化SANAS搜索实例</a></li> <li class="toctree-l3"><a class="reference internal" href="#sanas">2. 初始化SANAS搜索实例</a></li>
<li class="toctree-l3"><a class="reference internal" href="#id3">3. 构建网络</a></li> <li class="toctree-l3"><a class="reference internal" href="#id4">3. 构建网络</a></li>
<li class="toctree-l3"><a class="reference internal" href="#id4">4. 定义输入数据函数</a></li> <li class="toctree-l3"><a class="reference internal" href="#id5">4. 定义输入数据函数</a></li>
<li class="toctree-l3"><a class="reference internal" href="#id5">5. 定义训练函数</a></li> <li class="toctree-l3"><a class="reference internal" href="#id6">5. 定义训练函数</a></li>
<li class="toctree-l3"><a class="reference internal" href="#id6">6. 定义评估函数</a></li> <li class="toctree-l3"><a class="reference internal" href="#id7">6. 定义评估函数</a></li>
<li class="toctree-l3"><a class="reference internal" href="#id7">7. 启动搜索实验</a><ul> <li class="toctree-l3"><a class="reference internal" href="#id8">7. 启动搜索实验</a><ul>
<li class="toctree-l4"><a class="reference internal" href="#id8">7.1 获取模型结构</a></li> <li class="toctree-l4"><a class="reference internal" href="#id9">7.1 获取模型结构</a></li>
<li class="toctree-l4"><a class="reference internal" href="#program">7.2 构造program</a></li> <li class="toctree-l4"><a class="reference internal" href="#program">7.2 构造program</a></li>
<li class="toctree-l4"><a class="reference internal" href="#id9">7.3 定义输入数据</a></li> <li class="toctree-l4"><a class="reference internal" href="#id10">7.3 定义输入数据</a></li>
<li class="toctree-l4"><a class="reference internal" href="#id10">7.4 训练模型</a></li> <li class="toctree-l4"><a class="reference internal" href="#id11">7.4 训练模型</a></li>
<li class="toctree-l4"><a class="reference internal" href="#id11">7.5 评估模型</a></li> <li class="toctree-l4"><a class="reference internal" href="#id12">7.5 评估模型</a></li>
<li class="toctree-l4"><a class="reference internal" href="#id12">7.6 回传当前模型的得分</a></li> <li class="toctree-l4"><a class="reference internal" href="#id13">7.6 回传当前模型的得分</a></li>
</ul> </ul>
</li> </li>
<li class="toctree-l3"><a class="reference internal" href="#id13">8. 完整示例</a></li> <li class="toctree-l3"><a class="reference internal" href="#id14">8. 完整示例</a></li>
</ul> </ul>
</li> </li>
</ul> </ul>
...@@ -163,9 +163,9 @@ ...@@ -163,9 +163,9 @@
<div class="section" id="id1"> <div class="section" id="id1">
<h1>图像分类网络结构搜索-快速开始<a class="headerlink" href="#id1" title="永久链接至标题"></a></h1> <h1>图像分类网络结构搜索-快速开始<a class="headerlink" href="#id1" title="永久链接至标题"></a></h1>
<p>该教程以图像分类模型MobileNetV2为例,说明如何在cifar10数据集上快速使用<a class="reference external" href="../api/nas_api">网络结构搜索接口</a> <p>该教程以图像分类模型MobileNetV2为例,说明如何在cifar10数据集上快速使用<a class="reference external" href="../api/nas_api.md">网络结构搜索接口</a>
该示例包含以下步骤:</p> 该示例包含以下步骤:</p>
<ol class="simple"> <ol class="arabic simple">
<li>导入依赖</li> <li>导入依赖</li>
<li>初始化SANAS搜索实例</li> <li>初始化SANAS搜索实例</li>
<li>构建网络</li> <li>构建网络</li>
...@@ -182,8 +182,8 @@ ...@@ -182,8 +182,8 @@
<li>完整示例</li> <li>完整示例</li>
</ol> </ol>
<p>以下章节依次介绍每个步骤的内容。</p> <p>以下章节依次介绍每个步骤的内容。</p>
<div class="section" id="id2"> <div class="section" id="id3">
<h2>1. 导入依赖<a class="headerlink" href="#id2" title="永久链接至标题"></a></h2> <h2>1. 导入依赖<a class="headerlink" href="#id3" title="永久链接至标题"></a></h2>
<p>请确认已正确安装Paddle,导入需要的依赖包。</p> <p>请确认已正确安装Paddle,导入需要的依赖包。</p>
<div class="highlight-python"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">paddle</span> <div class="highlight-python"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">paddle</span>
<span class="kn">import</span> <span class="nn">paddle.fluid</span> <span class="k">as</span> <span class="nn">fluid</span> <span class="kn">import</span> <span class="nn">paddle.fluid</span> <span class="k">as</span> <span class="nn">fluid</span>
...@@ -198,8 +198,8 @@ ...@@ -198,8 +198,8 @@
</pre></div> </pre></div>
</div> </div>
</div> </div>
<div class="section" id="id3"> <div class="section" id="id4">
<h2>3. 构建网络<a class="headerlink" href="#id3" title="永久链接至标题"></a></h2> <h2>3. 构建网络<a class="headerlink" href="#id4" title="永久链接至标题"></a></h2>
<p>根据传入的网络结构构造训练program和测试program。</p> <p>根据传入的网络结构构造训练program和测试program。</p>
<div class="highlight-python"><div class="highlight"><pre><span></span><span class="k">def</span> <span class="nf">build_program</span><span class="p">(</span><span class="n">archs</span><span class="p">):</span> <div class="highlight-python"><div class="highlight"><pre><span></span><span class="k">def</span> <span class="nf">build_program</span><span class="p">(</span><span class="n">archs</span><span class="p">):</span>
<span class="n">train_program</span> <span class="o">=</span> <span class="n">fluid</span><span class="o">.</span><span class="n">Program</span><span class="p">()</span> <span class="n">train_program</span> <span class="o">=</span> <span class="n">fluid</span><span class="o">.</span><span class="n">Program</span><span class="p">()</span>
...@@ -227,8 +227,8 @@ ...@@ -227,8 +227,8 @@
</pre></div> </pre></div>
</div> </div>
</div> </div>
<div class="section" id="id4"> <div class="section" id="id5">
<h2>4. 定义输入数据函数<a class="headerlink" href="#id4" title="永久链接至标题"></a></h2> <h2>4. 定义输入数据函数<a class="headerlink" href="#id5" title="永久链接至标题"></a></h2>
<p>使用的数据集为cifar10,paddle框架中<code class="docutils literal"><span class="pre">paddle.dataset.cifar</span></code>包括了cifar数据集的下载和读取,代码如下:</p> <p>使用的数据集为cifar10,paddle框架中<code class="docutils literal"><span class="pre">paddle.dataset.cifar</span></code>包括了cifar数据集的下载和读取,代码如下:</p>
<div class="highlight-python"><div class="highlight"><pre><span></span><span class="k">def</span> <span class="nf">input_data</span><span class="p">(</span><span class="n">inputs</span><span class="p">):</span> <div class="highlight-python"><div class="highlight"><pre><span></span><span class="k">def</span> <span class="nf">input_data</span><span class="p">(</span><span class="n">inputs</span><span class="p">):</span>
<span class="n">train_reader</span> <span class="o">=</span> <span class="n">paddle</span><span class="o">.</span><span class="n">batch</span><span class="p">(</span><span class="n">paddle</span><span class="o">.</span><span class="n">reader</span><span class="o">.</span><span class="n">shuffle</span><span class="p">(</span><span class="n">paddle</span><span class="o">.</span><span class="n">dataset</span><span class="o">.</span><span class="n">cifar</span><span class="o">.</span><span class="n">train10</span><span class="p">(</span><span class="n">cycle</span><span class="o">=</span><span class="kc">False</span><span class="p">),</span> <span class="n">buf_size</span><span class="o">=</span><span class="mi">1024</span><span class="p">),</span><span class="n">batch_size</span><span class="o">=</span><span class="mi">256</span><span class="p">)</span> <span class="n">train_reader</span> <span class="o">=</span> <span class="n">paddle</span><span class="o">.</span><span class="n">batch</span><span class="p">(</span><span class="n">paddle</span><span class="o">.</span><span class="n">reader</span><span class="o">.</span><span class="n">shuffle</span><span class="p">(</span><span class="n">paddle</span><span class="o">.</span><span class="n">dataset</span><span class="o">.</span><span class="n">cifar</span><span class="o">.</span><span class="n">train10</span><span class="p">(</span><span class="n">cycle</span><span class="o">=</span><span class="kc">False</span><span class="p">),</span> <span class="n">buf_size</span><span class="o">=</span><span class="mi">1024</span><span class="p">),</span><span class="n">batch_size</span><span class="o">=</span><span class="mi">256</span><span class="p">)</span>
...@@ -239,8 +239,8 @@ ...@@ -239,8 +239,8 @@
</pre></div> </pre></div>
</div> </div>
</div> </div>
<div class="section" id="id5"> <div class="section" id="id6">
<h2>5. 定义训练函数<a class="headerlink" href="#id5" title="永久链接至标题"></a></h2> <h2>5. 定义训练函数<a class="headerlink" href="#id6" title="永久链接至标题"></a></h2>
<p>根据训练program和训练数据进行训练。</p> <p>根据训练program和训练数据进行训练。</p>
<div class="highlight-python"><div class="highlight"><pre><span></span><span class="k">def</span> <span class="nf">start_train</span><span class="p">(</span><span class="n">program</span><span class="p">,</span> <span class="n">data_reader</span><span class="p">,</span> <span class="n">data_feeder</span><span class="p">):</span> <div class="highlight-python"><div class="highlight"><pre><span></span><span class="k">def</span> <span class="nf">start_train</span><span class="p">(</span><span class="n">program</span><span class="p">,</span> <span class="n">data_reader</span><span class="p">,</span> <span class="n">data_feeder</span><span class="p">):</span>
<span class="n">outputs</span> <span class="o">=</span> <span class="p">[</span><span class="n">avg_cost</span><span class="o">.</span><span class="n">name</span><span class="p">,</span> <span class="n">acc_top1</span><span class="o">.</span><span class="n">name</span><span class="p">,</span> <span class="n">acc_top5</span><span class="o">.</span><span class="n">name</span><span class="p">]</span> <span class="n">outputs</span> <span class="o">=</span> <span class="p">[</span><span class="n">avg_cost</span><span class="o">.</span><span class="n">name</span><span class="p">,</span> <span class="n">acc_top1</span><span class="o">.</span><span class="n">name</span><span class="p">,</span> <span class="n">acc_top5</span><span class="o">.</span><span class="n">name</span><span class="p">]</span>
...@@ -250,8 +250,8 @@ ...@@ -250,8 +250,8 @@
</pre></div> </pre></div>
</div> </div>
</div> </div>
<div class="section" id="id6"> <div class="section" id="id7">
<h2>6. 定义评估函数<a class="headerlink" href="#id6" title="永久链接至标题"></a></h2> <h2>6. 定义评估函数<a class="headerlink" href="#id7" title="永久链接至标题"></a></h2>
<p>根据评估program和评估数据进行评估。</p> <p>根据评估program和评估数据进行评估。</p>
<div class="highlight-python"><div class="highlight"><pre><span></span><span class="k">def</span> <span class="nf">start_eval</span><span class="p">(</span><span class="n">program</span><span class="p">,</span> <span class="n">data_reader</span><span class="p">,</span> <span class="n">data_feeder</span><span class="p">):</span> <div class="highlight-python"><div class="highlight"><pre><span></span><span class="k">def</span> <span class="nf">start_eval</span><span class="p">(</span><span class="n">program</span><span class="p">,</span> <span class="n">data_reader</span><span class="p">,</span> <span class="n">data_feeder</span><span class="p">):</span>
<span class="n">reward</span> <span class="o">=</span> <span class="p">[]</span> <span class="n">reward</span> <span class="o">=</span> <span class="p">[]</span>
...@@ -267,11 +267,11 @@ ...@@ -267,11 +267,11 @@
</pre></div> </pre></div>
</div> </div>
</div> </div>
<div class="section" id="id7">
<h2>7. 启动搜索实验<a class="headerlink" href="#id7" title="永久链接至标题"></a></h2>
<p>以下步骤拆解说明了如何获得当前模型结构以及获得当前模型结构之后应该有的步骤,如果想要看如何启动搜索实验的完整示例可以看步骤9。</p>
<div class="section" id="id8"> <div class="section" id="id8">
<h3>7.1 获取模型结构<a class="headerlink" href="#id8" title="永久链接至标题"></a></h3> <h2>7. 启动搜索实验<a class="headerlink" href="#id8" title="永久链接至标题"></a></h2>
<p>以下步骤拆解说明了如何获得当前模型结构以及获得当前模型结构之后应该有的步骤,如果想要看如何启动搜索实验的完整示例可以看步骤9。</p>
<div class="section" id="id9">
<h3>7.1 获取模型结构<a class="headerlink" href="#id9" title="永久链接至标题"></a></h3>
<p>调用<code class="docutils literal"><span class="pre">next_archs()</span></code>函数获取到下一个模型结构。</p> <p>调用<code class="docutils literal"><span class="pre">next_archs()</span></code>函数获取到下一个模型结构。</p>
<div class="highlight-python"><div class="highlight"><pre><span></span><span class="n">archs</span> <span class="o">=</span> <span class="n">sanas</span><span class="o">.</span><span class="n">next_archs</span><span class="p">()[</span><span class="mi">0</span><span class="p">]</span> <div class="highlight-python"><div class="highlight"><pre><span></span><span class="n">archs</span> <span class="o">=</span> <span class="n">sanas</span><span class="o">.</span><span class="n">next_archs</span><span class="p">()[</span><span class="mi">0</span><span class="p">]</span>
</pre></div> </pre></div>
...@@ -284,35 +284,35 @@ ...@@ -284,35 +284,35 @@
</pre></div> </pre></div>
</div> </div>
</div> </div>
<div class="section" id="id9"> <div class="section" id="id10">
<h3>7.3 定义输入数据<a class="headerlink" href="#id9" title="永久链接至标题"></a></h3> <h3>7.3 定义输入数据<a class="headerlink" href="#id10" title="永久链接至标题"></a></h3>
<div class="highlight-python"><div class="highlight"><pre><span></span><span class="n">train_reader</span><span class="p">,</span> <span class="n">train_feeder</span><span class="p">,</span> <span class="n">eval_reader</span><span class="p">,</span> <span class="n">eval_feeder</span> <span class="o">=</span> <span class="n">input_data</span><span class="p">(</span><span class="n">inputs</span><span class="p">)</span> <div class="highlight-python"><div class="highlight"><pre><span></span><span class="n">train_reader</span><span class="p">,</span> <span class="n">train_feeder</span><span class="p">,</span> <span class="n">eval_reader</span><span class="p">,</span> <span class="n">eval_feeder</span> <span class="o">=</span> <span class="n">input_data</span><span class="p">(</span><span class="n">inputs</span><span class="p">)</span>
</pre></div> </pre></div>
</div> </div>
</div> </div>
<div class="section" id="id10"> <div class="section" id="id11">
<h3>7.4 训练模型<a class="headerlink" href="#id10" title="永久链接至标题"></a></h3> <h3>7.4 训练模型<a class="headerlink" href="#id11" title="永久链接至标题"></a></h3>
<p>根据上面得到的训练program和评估数据启动训练。</p> <p>根据上面得到的训练program和评估数据启动训练。</p>
<div class="highlight-python"><div class="highlight"><pre><span></span><span class="n">start_train</span><span class="p">(</span><span class="n">train_program</span><span class="p">,</span> <span class="n">train_reader</span><span class="p">,</span> <span class="n">train_feeder</span><span class="p">)</span> <div class="highlight-python"><div class="highlight"><pre><span></span><span class="n">start_train</span><span class="p">(</span><span class="n">train_program</span><span class="p">,</span> <span class="n">train_reader</span><span class="p">,</span> <span class="n">train_feeder</span><span class="p">)</span>
</pre></div> </pre></div>
</div> </div>
</div> </div>
<div class="section" id="id11"> <div class="section" id="id12">
<h3>7.5 评估模型<a class="headerlink" href="#id11" title="永久链接至标题"></a></h3> <h3>7.5 评估模型<a class="headerlink" href="#id12" title="永久链接至标题"></a></h3>
<p>根据上面得到的评估program和评估数据启动评估。</p> <p>根据上面得到的评估program和评估数据启动评估。</p>
<div class="highlight-python"><div class="highlight"><pre><span></span><span class="n">finally_reward</span> <span class="o">=</span> <span class="n">start_eval</span><span class="p">(</span><span class="n">eval_program</span><span class="p">,</span> <span class="n">eval_reader</span><span class="p">,</span> <span class="n">eval_feeder</span><span class="p">)</span> <div class="highlight-python"><div class="highlight"><pre><span></span><span class="n">finally_reward</span> <span class="o">=</span> <span class="n">start_eval</span><span class="p">(</span><span class="n">eval_program</span><span class="p">,</span> <span class="n">eval_reader</span><span class="p">,</span> <span class="n">eval_feeder</span><span class="p">)</span>
</pre></div> </pre></div>
</div> </div>
</div> </div>
<div class="section" id="id12"> <div class="section" id="id13">
<h3>7.6 回传当前模型的得分<a class="headerlink" href="#id12" title="永久链接至标题"></a></h3> <h3>7.6 回传当前模型的得分<a class="headerlink" href="#id13" title="永久链接至标题"></a></h3>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">sanas</span><span class="o">.</span><span class="n">reward</span><span class="p">(</span><span class="nb">float</span><span class="p">(</span><span class="n">finally_reward</span><span class="p">[</span><span class="mi">1</span><span class="p">]))</span> <div class="highlight-guess"><div class="highlight"><pre><span></span><span class="err">sanas.reward(float(finally_reward[1]))</span>
</pre></div> </pre></div>
</div> </div>
</div> </div>
</div> </div>
<div class="section" id="id13"> <div class="section" id="id14">
<h2>8. 完整示例<a class="headerlink" href="#id13" title="永久链接至标题"></a></h2> <h2>8. 完整示例<a class="headerlink" href="#id14" title="永久链接至标题"></a></h2>
<p>以下是一个完整的搜索实验示例,示例中使用FLOPs作为约束条件,搜索实验一共搜索3个step,表示搜索到3个满足条件的模型结构进行训练,每搜索到一个网络结构训练7个epoch。</p> <p>以下是一个完整的搜索实验示例,示例中使用FLOPs作为约束条件,搜索实验一共搜索3个step,表示搜索到3个满足条件的模型结构进行训练,每搜索到一个网络结构训练7个epoch。</p>
<div class="highlight-python"><div class="highlight"><pre><span></span><span class="k">for</span> <span class="n">step</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="mi">3</span><span class="p">):</span> <div class="highlight-python"><div class="highlight"><pre><span></span><span class="k">for</span> <span class="n">step</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="mi">3</span><span class="p">):</span>
<span class="n">archs</span> <span class="o">=</span> <span class="n">sanas</span><span class="o">.</span><span class="n">next_archs</span><span class="p">()[</span><span class="mi">0</span><span class="p">]</span> <span class="n">archs</span> <span class="o">=</span> <span class="n">sanas</span><span class="o">.</span><span class="n">next_archs</span><span class="p">()[</span><span class="mi">0</span><span class="p">]</span>
......
...@@ -161,8 +161,8 @@ ...@@ -161,8 +161,8 @@
<div class="section" id="nerual-architecture-search-for-image-classification"> <div class="section" id="nerual-architecture-search-for-image-classification">
<h1>Nerual Architecture Search for Image Classification<a class="headerlink" href="#nerual-architecture-search-for-image-classification" title="Permalink to this headline"></a></h1> <h1>Nerual Architecture Search for Image Classification<a class="headerlink" href="#nerual-architecture-search-for-image-classification" title="Permalink to this headline"></a></h1>
<p>This tutorial shows how to use <a class="reference external" href="../api/nas_api">API</a> about SANAS in PaddleSlim. We start experiment based on MobileNetV2 as example. The tutorial contains follow section.</p> <p>This tutorial shows how to use <a class="reference external" href="../api/nas_api.md">API</a> about SANAS in PaddleSlim. We start experiment based on MobileNetV2 as example. The tutorial contains follow section.</p>
<ol class="simple"> <ol class="arabic simple">
<li>necessary imports</li> <li>necessary imports</li>
<li>initial SANAS instance</li> <li>initial SANAS instance</li>
<li>define function about building program</li> <li>define function about building program</li>
...@@ -303,7 +303,7 @@ ...@@ -303,7 +303,7 @@
</div> </div>
<div class="section" id="reture-score"> <div class="section" id="reture-score">
<h3>7.6 reture score<a class="headerlink" href="#reture-score" title="Permalink to this headline"></a></h3> <h3>7.6 reture score<a class="headerlink" href="#reture-score" title="Permalink to this headline"></a></h3>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">sanas</span><span class="o">.</span><span class="n">reward</span><span class="p">(</span><span class="nb">float</span><span class="p">(</span><span class="n">finally_reward</span><span class="p">[</span><span class="mi">1</span><span class="p">]))</span> <div class="highlight-guess"><div class="highlight"><pre><span></span><span class="err">sanas.reward(float(finally_reward[1]))</span>
</pre></div> </pre></div>
</div> </div>
</div> </div>
......
...@@ -83,7 +83,7 @@ ...@@ -83,7 +83,7 @@
<ul class="current"> <ul class="current">
<li class="toctree-l1"><a class="reference internal" href="../index_en.html">English Documents</a></li> <li class="toctree-l1"><a class="reference internal" href="../index_en.html">English Documents</a></li>
<li class="toctree-l1"><a class="reference internal" href="../intro.html">PaddleSlim简介</a></li> <li class="toctree-l1"><a class="reference internal" href="../intro.html">介绍</a></li>
<li class="toctree-l1"><a class="reference internal" href="../install.html">安装</a></li> <li class="toctree-l1"><a class="reference internal" href="../install.html">安装</a></li>
<li class="toctree-l1 current"><a class="reference internal" href="index.html">快速开始</a><ul class="current"> <li class="toctree-l1 current"><a class="reference internal" href="index.html">快速开始</a><ul class="current">
<li class="toctree-l2 current"><a class="current reference internal" href="#">图像分类模型通道剪裁-快速开始</a><ul> <li class="toctree-l2 current"><a class="current reference internal" href="#">图像分类模型通道剪裁-快速开始</a><ul>
...@@ -160,9 +160,9 @@ ...@@ -160,9 +160,9 @@
<div class="section" id="id1"> <div class="section" id="id1">
<h1>图像分类模型通道剪裁-快速开始<a class="headerlink" href="#id1" title="永久链接至标题"></a></h1> <h1>图像分类模型通道剪裁-快速开始<a class="headerlink" href="#id1" title="永久链接至标题"></a></h1>
<p>该教程以图像分类模型MobileNetV1为例,说明如何快速使用<a class="reference external" href="#">PaddleSlim的卷积通道剪裁接口</a> <p>该教程以图像分类模型MobileNetV1为例,说明如何快速使用<a href="#id10"><span class="problematic" id="id11">`PaddleSlim的卷积通道剪裁接口 &lt;&gt;`_</span></a>
该示例包含以下步骤:</p> 该示例包含以下步骤:</p>
<ol class="simple"> <ol class="arabic simple">
<li>导入依赖</li> <li>导入依赖</li>
<li>构建模型</li> <li>构建模型</li>
<li>剪裁</li> <li>剪裁</li>
...@@ -172,9 +172,9 @@ ...@@ -172,9 +172,9 @@
<div class="section" id="id2"> <div class="section" id="id2">
<h2>1. 导入依赖<a class="headerlink" href="#id2" title="永久链接至标题"></a></h2> <h2>1. 导入依赖<a class="headerlink" href="#id2" title="永久链接至标题"></a></h2>
<p>PaddleSlim依赖Paddle1.7版本,请确认已正确安装Paddle,然后按以下方式导入Paddle和PaddleSlim:</p> <p>PaddleSlim依赖Paddle1.7版本,请确认已正确安装Paddle,然后按以下方式导入Paddle和PaddleSlim:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">paddle</span> <div class="highlight-guess"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">paddle</span>
<span class="kn">import</span> <span class="nn">paddle.fluid</span> <span class="k">as</span> <span class="nn">fluid</span> <span class="kn">import</span> <span class="nn">paddle.fluid</span> <span class="kn">as</span> <span class="nn">fluid</span>
<span class="kn">import</span> <span class="nn">paddleslim</span> <span class="k">as</span> <span class="nn">slim</span> <span class="kn">import</span> <span class="nn">paddleslim</span> <span class="kn">as</span> <span class="nn">slim</span>
</pre></div> </pre></div>
</div> </div>
</div> </div>
...@@ -182,8 +182,8 @@ ...@@ -182,8 +182,8 @@
<h2>2. 构建网络<a class="headerlink" href="#id3" title="永久链接至标题"></a></h2> <h2>2. 构建网络<a class="headerlink" href="#id3" title="永久链接至标题"></a></h2>
<p>该章节构造一个用于对MNIST数据进行分类的分类模型,选用<code class="docutils literal"><span class="pre">MobileNetV1</span></code>,并将输入大小设置为<code class="docutils literal"><span class="pre">[1,</span> <span class="pre">28,</span> <span class="pre">28]</span></code>,输出类别数为10。 <p>该章节构造一个用于对MNIST数据进行分类的分类模型,选用<code class="docutils literal"><span class="pre">MobileNetV1</span></code>,并将输入大小设置为<code class="docutils literal"><span class="pre">[1,</span> <span class="pre">28,</span> <span class="pre">28]</span></code>,输出类别数为10。
为了方便展示示例,我们在<code class="docutils literal"><span class="pre">paddleslim.models</span></code>下预定义了用于构建分类模型的方法,执行以下代码构建分类模型:</p> 为了方便展示示例,我们在<code class="docutils literal"><span class="pre">paddleslim.models</span></code>下预定义了用于构建分类模型的方法,执行以下代码构建分类模型:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">exe</span><span class="p">,</span> <span class="n">train_program</span><span class="p">,</span> <span class="n">val_program</span><span class="p">,</span> <span class="n">inputs</span><span class="p">,</span> <span class="n">outputs</span> <span class="o">=</span> <div class="highlight-guess"><div class="highlight"><pre><span></span><span class="err">exe, train_program, val_program, inputs, outputs =</span>
<span class="n">slim</span><span class="o">.</span><span class="n">models</span><span class="o">.</span><span class="n">image_classification</span><span class="p">(</span><span class="s2">&quot;MobileNet&quot;</span><span class="p">,</span> <span class="p">[</span><span class="mi">1</span><span class="p">,</span> <span class="mi">28</span><span class="p">,</span> <span class="mi">28</span><span class="p">],</span> <span class="mi">10</span><span class="p">,</span> <span class="n">use_gpu</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span> <span class="err"> slim.models.image_classification(&quot;MobileNet&quot;, [1, 28, 28], 10, use_gpu=False)</span>
</pre></div> </pre></div>
</div> </div>
<blockquote> <blockquote>
...@@ -193,8 +193,8 @@ ...@@ -193,8 +193,8 @@
<h2>3. 剪裁卷积层通道<a class="headerlink" href="#id4" title="永久链接至标题"></a></h2> <h2>3. 剪裁卷积层通道<a class="headerlink" href="#id4" title="永久链接至标题"></a></h2>
<div class="section" id="flops"> <div class="section" id="flops">
<h3>3.1 计算剪裁之前的FLOPs<a class="headerlink" href="#flops" title="永久链接至标题"></a></h3> <h3>3.1 计算剪裁之前的FLOPs<a class="headerlink" href="#flops" title="永久链接至标题"></a></h3>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">FLOPs</span> <span class="o">=</span> <span class="n">slim</span><span class="o">.</span><span class="n">analysis</span><span class="o">.</span><span class="n">flops</span><span class="p">(</span><span class="n">train_program</span><span class="p">)</span> <div class="highlight-guess"><div class="highlight"><pre><span></span><span class="err">FLOPs = slim.analysis.flops(train_program)</span>
<span class="nb">print</span><span class="p">(</span><span class="s2">&quot;FLOPs: </span><span class="si">{}</span><span class="s2">&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">FLOPs</span><span class="p">))</span> <span class="err">print(&quot;FLOPs: {}&quot;.format(FLOPs))</span>
</pre></div> </pre></div>
</div> </div>
</div> </div>
...@@ -202,21 +202,21 @@ ...@@ -202,21 +202,21 @@
<h3>3.2 剪裁<a class="headerlink" href="#id5" title="永久链接至标题"></a></h3> <h3>3.2 剪裁<a class="headerlink" href="#id5" title="永久链接至标题"></a></h3>
<p>我们这里对参数名为<code class="docutils literal"><span class="pre">conv2_1_sep_weights</span></code><code class="docutils literal"><span class="pre">conv2_2_sep_weights</span></code>的卷积层进行剪裁,分别剪掉20%和30%的通道数。 <p>我们这里对参数名为<code class="docutils literal"><span class="pre">conv2_1_sep_weights</span></code><code class="docutils literal"><span class="pre">conv2_2_sep_weights</span></code>的卷积层进行剪裁,分别剪掉20%和30%的通道数。
代码如下所示:</p> 代码如下所示:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">pruner</span> <span class="o">=</span> <span class="n">slim</span><span class="o">.</span><span class="n">prune</span><span class="o">.</span><span class="n">Pruner</span><span class="p">()</span> <div class="highlight-guess"><div class="highlight"><pre><span></span><span class="err">pruner = slim.prune.Pruner()</span>
<span class="n">pruned_program</span><span class="p">,</span> <span class="n">_</span><span class="p">,</span> <span class="n">_</span> <span class="o">=</span> <span class="n">pruner</span><span class="o">.</span><span class="n">prune</span><span class="p">(</span> <span class="err">pruned_program, _, _ = pruner.prune(</span>
<span class="n">train_program</span><span class="p">,</span> <span class="err"> train_program,</span>
<span class="n">fluid</span><span class="o">.</span><span class="n">global_scope</span><span class="p">(),</span> <span class="err"> fluid.global_scope(),</span>
<span class="n">params</span><span class="o">=</span><span class="p">[</span><span class="s2">&quot;conv2_1_sep_weights&quot;</span><span class="p">,</span> <span class="s2">&quot;conv2_2_sep_weights&quot;</span><span class="p">],</span> <span class="err"> params=[&quot;conv2_1_sep_weights&quot;, &quot;conv2_2_sep_weights&quot;],</span>
<span class="n">ratios</span><span class="o">=</span><span class="p">[</span><span class="mf">0.33</span><span class="p">]</span> <span class="o">*</span> <span class="mi">2</span><span class="p">,</span> <span class="err"> ratios=[0.33] * 2,</span>
<span class="n">place</span><span class="o">=</span><span class="n">fluid</span><span class="o">.</span><span class="n">CPUPlace</span><span class="p">())</span> <span class="err"> place=fluid.CPUPlace())</span>
</pre></div> </pre></div>
</div> </div>
<p>以上操作会修改<code class="docutils literal"><span class="pre">train_program</span></code>中对应卷积层参数的定义,同时对<code class="docutils literal"><span class="pre">fluid.global_scope()</span></code>中存储的参数数组进行裁剪。</p> <p>以上操作会修改<code class="docutils literal"><span class="pre">train_program</span></code>中对应卷积层参数的定义,同时对<code class="docutils literal"><span class="pre">fluid.global_scope()</span></code>中存储的参数数组进行裁剪。</p>
</div> </div>
<div class="section" id="id6"> <div class="section" id="id6">
<h3>3.3 计算剪裁之后的FLOPs<a class="headerlink" href="#id6" title="永久链接至标题"></a></h3> <h3>3.3 计算剪裁之后的FLOPs<a class="headerlink" href="#id6" title="永久链接至标题"></a></h3>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">FLOPs</span> <span class="o">=</span> <span class="n">paddleslim</span><span class="o">.</span><span class="n">analysis</span><span class="o">.</span><span class="n">flops</span><span class="p">(</span><span class="n">train_program</span><span class="p">)</span> <div class="highlight-guess"><div class="highlight"><pre><span></span><span class="err">FLOPs = paddleslim.analysis.flops(train_program)</span>
<span class="nb">print</span><span class="p">(</span><span class="s2">&quot;FLOPs: </span><span class="si">{}</span><span class="s2">&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">FLOPs</span><span class="p">))</span> <span class="err">print(&quot;FLOPs: {}&quot;.format(FLOPs))</span>
</pre></div> </pre></div>
</div> </div>
</div> </div>
...@@ -227,9 +227,9 @@ ...@@ -227,9 +227,9 @@
<h3>4.1 定义输入数据<a class="headerlink" href="#id8" title="永久链接至标题"></a></h3> <h3>4.1 定义输入数据<a class="headerlink" href="#id8" title="永久链接至标题"></a></h3>
<p>为了快速执行该示例,我们选取简单的MNIST数据,Paddle框架的<code class="docutils literal"><span class="pre">paddle.dataset.mnist</span></code>包定义了MNIST数据的下载和读取。 <p>为了快速执行该示例,我们选取简单的MNIST数据,Paddle框架的<code class="docutils literal"><span class="pre">paddle.dataset.mnist</span></code>包定义了MNIST数据的下载和读取。
代码如下:</p> 代码如下:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">paddle.dataset.mnist</span> <span class="k">as</span> <span class="nn">reader</span> <div class="highlight-guess"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">paddle.dataset.mnist</span> <span class="kn">as</span> <span class="nn">reader</span>
<span class="n">train_reader</span> <span class="o">=</span> <span class="n">paddle</span><span class="o">.</span><span class="n">batch</span><span class="p">(</span> <span class="n">train_reader</span> <span class="o">=</span> <span class="n">paddle</span><span class="o">.</span><span class="n">batch</span><span class="p">(</span>
<span class="n">reader</span><span class="o">.</span><span class="n">train</span><span class="p">(),</span> <span class="n">batch_size</span><span class="o">=</span><span class="mi">128</span><span class="p">,</span> <span class="n">drop_last</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> <span class="n">reader</span><span class="o">.</span><span class="n">train</span><span class="p">(),</span> <span class="n">batch_size</span><span class="o">=</span><span class="mi">128</span><span class="p">,</span> <span class="n">drop_last</span><span class="o">=</span><span class="bp">True</span><span class="p">)</span>
<span class="n">train_feeder</span> <span class="o">=</span> <span class="n">fluid</span><span class="o">.</span><span class="n">DataFeeder</span><span class="p">(</span><span class="n">inputs</span><span class="p">,</span> <span class="n">fluid</span><span class="o">.</span><span class="n">CPUPlace</span><span class="p">())</span> <span class="n">train_feeder</span> <span class="o">=</span> <span class="n">fluid</span><span class="o">.</span><span class="n">DataFeeder</span><span class="p">(</span><span class="n">inputs</span><span class="p">,</span> <span class="n">fluid</span><span class="o">.</span><span class="n">CPUPlace</span><span class="p">())</span>
</pre></div> </pre></div>
</div> </div>
...@@ -237,9 +237,9 @@ ...@@ -237,9 +237,9 @@
<div class="section" id="id9"> <div class="section" id="id9">
<h3>4.2 执行训练<a class="headerlink" href="#id9" title="永久链接至标题"></a></h3> <h3>4.2 执行训练<a class="headerlink" href="#id9" title="永久链接至标题"></a></h3>
<p>以下代码执行了一个<code class="docutils literal"><span class="pre">epoch</span></code>的训练:</p> <p>以下代码执行了一个<code class="docutils literal"><span class="pre">epoch</span></code>的训练:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="k">for</span> <span class="n">data</span> <span class="ow">in</span> <span class="n">train_reader</span><span class="p">():</span> <div class="highlight-guess"><div class="highlight"><pre><span></span><span class="err">for data in train_reader():</span>
<span class="n">acc1</span><span class="p">,</span> <span class="n">acc5</span><span class="p">,</span> <span class="n">loss</span> <span class="o">=</span> <span class="n">exe</span><span class="o">.</span><span class="n">run</span><span class="p">(</span><span class="n">pruned_program</span><span class="p">,</span> <span class="n">feed</span><span class="o">=</span><span class="n">train_feeder</span><span class="o">.</span><span class="n">feed</span><span class="p">(</span><span class="n">data</span><span class="p">),</span> <span class="n">fetch_list</span><span class="o">=</span><span class="n">outputs</span><span class="p">)</span> <span class="err"> acc1, acc5, loss = exe.run(pruned_program, feed=train_feeder.feed(data), fetch_list=outputs)</span>
<span class="nb">print</span><span class="p">(</span><span class="n">acc1</span><span class="p">,</span> <span class="n">acc5</span><span class="p">,</span> <span class="n">loss</span><span class="p">)</span> <span class="err"> print(acc1, acc5, loss)</span>
</pre></div> </pre></div>
</div> </div>
</div> </div>
......
...@@ -160,7 +160,7 @@ ...@@ -160,7 +160,7 @@
<h1>Channel Pruning for Image Classification<a class="headerlink" href="#channel-pruning-for-image-classification" title="Permalink to this headline"></a></h1> <h1>Channel Pruning for Image Classification<a class="headerlink" href="#channel-pruning-for-image-classification" title="Permalink to this headline"></a></h1>
<p>In this tutorial, you will learn how to use channel pruning API of PaddleSlim <p>In this tutorial, you will learn how to use channel pruning API of PaddleSlim
by a demo of MobileNetV1 model on MNIST dataset. This tutorial following workflow:</p> by a demo of MobileNetV1 model on MNIST dataset. This tutorial following workflow:</p>
<ol class="simple"> <ol class="arabic simple">
<li>Import dependency</li> <li>Import dependency</li>
<li>Build model</li> <li>Build model</li>
<li>Prune model</li> <li>Prune model</li>
...@@ -169,9 +169,9 @@ by a demo of MobileNetV1 model on MNIST dataset. This tutorial following workflo ...@@ -169,9 +169,9 @@ by a demo of MobileNetV1 model on MNIST dataset. This tutorial following workflo
<div class="section" id="import-dependency"> <div class="section" id="import-dependency">
<h2>1. Import dependency<a class="headerlink" href="#import-dependency" title="Permalink to this headline"></a></h2> <h2>1. Import dependency<a class="headerlink" href="#import-dependency" title="Permalink to this headline"></a></h2>
<p>PaddleSlim dependents on Paddle1.7. Please ensure that you have installed paddle correctly. Import Paddle and PaddleSlim as below:</p> <p>PaddleSlim dependents on Paddle1.7. Please ensure that you have installed paddle correctly. Import Paddle and PaddleSlim as below:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">paddle</span> <div class="highlight-guess"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">paddle</span>
<span class="kn">import</span> <span class="nn">paddle.fluid</span> <span class="k">as</span> <span class="nn">fluid</span> <span class="kn">import</span> <span class="nn">paddle.fluid</span> <span class="kn">as</span> <span class="nn">fluid</span>
<span class="kn">import</span> <span class="nn">paddleslim</span> <span class="k">as</span> <span class="nn">slim</span> <span class="kn">import</span> <span class="nn">paddleslim</span> <span class="kn">as</span> <span class="nn">slim</span>
</pre></div> </pre></div>
</div> </div>
</div> </div>
...@@ -180,8 +180,8 @@ by a demo of MobileNetV1 model on MNIST dataset. This tutorial following workflo ...@@ -180,8 +180,8 @@ by a demo of MobileNetV1 model on MNIST dataset. This tutorial following workflo
<p>This section will build a classsification model based <code class="docutils literal"><span class="pre">MobileNetV1</span></code> for MNIST task. The shape of the input is <code class="docutils literal"><span class="pre">[1,</span> <span class="pre">28,</span> <span class="pre">28]</span></code> and the output number is 10.</p> <p>This section will build a classsification model based <code class="docutils literal"><span class="pre">MobileNetV1</span></code> for MNIST task. The shape of the input is <code class="docutils literal"><span class="pre">[1,</span> <span class="pre">28,</span> <span class="pre">28]</span></code> and the output number is 10.</p>
<p>To make the code simple, we define a function in package <code class="docutils literal"><span class="pre">paddleslim.models</span></code> to build classification model. <p>To make the code simple, we define a function in package <code class="docutils literal"><span class="pre">paddleslim.models</span></code> to build classification model.
Excute following code to build a model,</p> Excute following code to build a model,</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">exe</span><span class="p">,</span> <span class="n">train_program</span><span class="p">,</span> <span class="n">val_program</span><span class="p">,</span> <span class="n">inputs</span><span class="p">,</span> <span class="n">outputs</span> <span class="o">=</span> <div class="highlight-guess"><div class="highlight"><pre><span></span><span class="err">exe, train_program, val_program, inputs, outputs =</span>
<span class="n">slim</span><span class="o">.</span><span class="n">models</span><span class="o">.</span><span class="n">image_classification</span><span class="p">(</span><span class="s2">&quot;MobileNet&quot;</span><span class="p">,</span> <span class="p">[</span><span class="mi">1</span><span class="p">,</span> <span class="mi">28</span><span class="p">,</span> <span class="mi">28</span><span class="p">],</span> <span class="mi">10</span><span class="p">,</span> <span class="n">use_gpu</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span> <span class="err"> slim.models.image_classification(&quot;MobileNet&quot;, [1, 28, 28], 10, use_gpu=False)</span>
</pre></div> </pre></div>
</div> </div>
<blockquote> <blockquote>
...@@ -191,29 +191,29 @@ Excute following code to build a model,</p> ...@@ -191,29 +191,29 @@ Excute following code to build a model,</p>
<h2>3. Prune model<a class="headerlink" href="#prune-model" title="Permalink to this headline"></a></h2> <h2>3. Prune model<a class="headerlink" href="#prune-model" title="Permalink to this headline"></a></h2>
<div class="section" id="compute-flops-bofore-pruning"> <div class="section" id="compute-flops-bofore-pruning">
<h3>3.1 Compute FLOPs bofore pruning<a class="headerlink" href="#compute-flops-bofore-pruning" title="Permalink to this headline"></a></h3> <h3>3.1 Compute FLOPs bofore pruning<a class="headerlink" href="#compute-flops-bofore-pruning" title="Permalink to this headline"></a></h3>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">FLOPs</span> <span class="o">=</span> <span class="n">slim</span><span class="o">.</span><span class="n">analysis</span><span class="o">.</span><span class="n">flops</span><span class="p">(</span><span class="n">train_program</span><span class="p">)</span> <div class="highlight-guess"><div class="highlight"><pre><span></span><span class="err">FLOPs = slim.analysis.flops(train_program)</span>
<span class="nb">print</span><span class="p">(</span><span class="s2">&quot;FLOPs: </span><span class="si">{}</span><span class="s2">&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">FLOPs</span><span class="p">))</span> <span class="err">print(&quot;FLOPs: {}&quot;.format(FLOPs))</span>
</pre></div> </pre></div>
</div> </div>
</div> </div>
<div class="section" id="pruning"> <div class="section" id="pruning">
<h3>3.2 Pruning<a class="headerlink" href="#pruning" title="Permalink to this headline"></a></h3> <h3>3.2 Pruning<a class="headerlink" href="#pruning" title="Permalink to this headline"></a></h3>
<p>The section will prune the parameters named <code class="docutils literal"><span class="pre">conv2_1_sep_weights</span></code> and <code class="docutils literal"><span class="pre">conv2_2_sep_weights</span></code> by 20% and 30%.</p> <p>The section will prune the parameters named <code class="docutils literal"><span class="pre">conv2_1_sep_weights</span></code> and <code class="docutils literal"><span class="pre">conv2_2_sep_weights</span></code> by 20% and 30%.</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">pruner</span> <span class="o">=</span> <span class="n">slim</span><span class="o">.</span><span class="n">prune</span><span class="o">.</span><span class="n">Pruner</span><span class="p">()</span> <div class="highlight-guess"><div class="highlight"><pre><span></span><span class="err">pruner = slim.prune.Pruner()</span>
<span class="n">pruned_program</span><span class="p">,</span> <span class="n">_</span><span class="p">,</span> <span class="n">_</span> <span class="o">=</span> <span class="n">pruner</span><span class="o">.</span><span class="n">prune</span><span class="p">(</span> <span class="err">pruned_program, _, _ = pruner.prune(</span>
<span class="n">train_program</span><span class="p">,</span> <span class="err"> train_program,</span>
<span class="n">fluid</span><span class="o">.</span><span class="n">global_scope</span><span class="p">(),</span> <span class="err"> fluid.global_scope(),</span>
<span class="n">params</span><span class="o">=</span><span class="p">[</span><span class="s2">&quot;conv2_1_sep_weights&quot;</span><span class="p">,</span> <span class="s2">&quot;conv2_2_sep_weights&quot;</span><span class="p">],</span> <span class="err"> params=[&quot;conv2_1_sep_weights&quot;, &quot;conv2_2_sep_weights&quot;],</span>
<span class="n">ratios</span><span class="o">=</span><span class="p">[</span><span class="mf">0.33</span><span class="p">]</span> <span class="o">*</span> <span class="mi">2</span><span class="p">,</span> <span class="err"> ratios=[0.33] * 2,</span>
<span class="n">place</span><span class="o">=</span><span class="n">fluid</span><span class="o">.</span><span class="n">CPUPlace</span><span class="p">())</span> <span class="err"> place=fluid.CPUPlace())</span>
</pre></div> </pre></div>
</div> </div>
<p>It will change the shapes of parameters defined in <code class="docutils literal"><span class="pre">train_program</span></code>. And the parameters<code class="docutils literal"><span class="pre">values</span> <span class="pre">stored</span> <span class="pre">in</span></code>fluid.global_scope()` will be pruned.</p> <p>It will change the shapes of parameters defined in <code class="docutils literal"><span class="pre">train_program</span></code>. And the parameters<code class="docutils literal"><span class="pre">values</span> <span class="pre">stored</span> <span class="pre">in</span></code>fluid.global_scope()` will be pruned.</p>
</div> </div>
<div class="section" id="compute-flops-after-pruning"> <div class="section" id="compute-flops-after-pruning">
<h3>3.3 Compute FLOPs after pruning<a class="headerlink" href="#compute-flops-after-pruning" title="Permalink to this headline"></a></h3> <h3>3.3 Compute FLOPs after pruning<a class="headerlink" href="#compute-flops-after-pruning" title="Permalink to this headline"></a></h3>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">FLOPs</span> <span class="o">=</span> <span class="n">paddleslim</span><span class="o">.</span><span class="n">analysis</span><span class="o">.</span><span class="n">flops</span><span class="p">(</span><span class="n">train_program</span><span class="p">)</span> <div class="highlight-guess"><div class="highlight"><pre><span></span><span class="err">FLOPs = paddleslim.analysis.flops(train_program)</span>
<span class="nb">print</span><span class="p">(</span><span class="s2">&quot;FLOPs: </span><span class="si">{}</span><span class="s2">&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">FLOPs</span><span class="p">))</span> <span class="err">print(&quot;FLOPs: {}&quot;.format(FLOPs))</span>
</pre></div> </pre></div>
</div> </div>
</div> </div>
...@@ -224,9 +224,9 @@ Excute following code to build a model,</p> ...@@ -224,9 +224,9 @@ Excute following code to build a model,</p>
<h3>4.1 Define dataset<a class="headerlink" href="#define-dataset" title="Permalink to this headline"></a></h3> <h3>4.1 Define dataset<a class="headerlink" href="#define-dataset" title="Permalink to this headline"></a></h3>
<p>To make you easily run this demo, it will training on MNIST dataset. The package <code class="docutils literal"><span class="pre">paddle.dataset.mnist</span></code> of Paddle defines the downloading and reading of MNIST dataset. <p>To make you easily run this demo, it will training on MNIST dataset. The package <code class="docutils literal"><span class="pre">paddle.dataset.mnist</span></code> of Paddle defines the downloading and reading of MNIST dataset.
Define training data reader and test data reader as below:</p> Define training data reader and test data reader as below:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">paddle.dataset.mnist</span> <span class="k">as</span> <span class="nn">reader</span> <div class="highlight-guess"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">paddle.dataset.mnist</span> <span class="kn">as</span> <span class="nn">reader</span>
<span class="n">train_reader</span> <span class="o">=</span> <span class="n">paddle</span><span class="o">.</span><span class="n">batch</span><span class="p">(</span> <span class="n">train_reader</span> <span class="o">=</span> <span class="n">paddle</span><span class="o">.</span><span class="n">batch</span><span class="p">(</span>
<span class="n">reader</span><span class="o">.</span><span class="n">train</span><span class="p">(),</span> <span class="n">batch_size</span><span class="o">=</span><span class="mi">128</span><span class="p">,</span> <span class="n">drop_last</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> <span class="n">reader</span><span class="o">.</span><span class="n">train</span><span class="p">(),</span> <span class="n">batch_size</span><span class="o">=</span><span class="mi">128</span><span class="p">,</span> <span class="n">drop_last</span><span class="o">=</span><span class="bp">True</span><span class="p">)</span>
<span class="n">train_feeder</span> <span class="o">=</span> <span class="n">fluid</span><span class="o">.</span><span class="n">DataFeeder</span><span class="p">(</span><span class="n">inputs</span><span class="p">,</span> <span class="n">fluid</span><span class="o">.</span><span class="n">CPUPlace</span><span class="p">())</span> <span class="n">train_feeder</span> <span class="o">=</span> <span class="n">fluid</span><span class="o">.</span><span class="n">DataFeeder</span><span class="p">(</span><span class="n">inputs</span><span class="p">,</span> <span class="n">fluid</span><span class="o">.</span><span class="n">CPUPlace</span><span class="p">())</span>
</pre></div> </pre></div>
</div> </div>
...@@ -234,9 +234,9 @@ Define training data reader and test data reader as below:</p> ...@@ -234,9 +234,9 @@ Define training data reader and test data reader as below:</p>
<div class="section" id="training"> <div class="section" id="training">
<h3>4.2 Training<a class="headerlink" href="#training" title="Permalink to this headline"></a></h3> <h3>4.2 Training<a class="headerlink" href="#training" title="Permalink to this headline"></a></h3>
<p>Excute following code to run an <code class="docutils literal"><span class="pre">epoch</span></code> training:</p> <p>Excute following code to run an <code class="docutils literal"><span class="pre">epoch</span></code> training:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="k">for</span> <span class="n">data</span> <span class="ow">in</span> <span class="n">train_reader</span><span class="p">():</span> <div class="highlight-guess"><div class="highlight"><pre><span></span><span class="err">for data in train_reader():</span>
<span class="n">acc1</span><span class="p">,</span> <span class="n">acc5</span><span class="p">,</span> <span class="n">loss</span> <span class="o">=</span> <span class="n">exe</span><span class="o">.</span><span class="n">run</span><span class="p">(</span><span class="n">pruned_program</span><span class="p">,</span> <span class="n">feed</span><span class="o">=</span><span class="n">train_feeder</span><span class="o">.</span><span class="n">feed</span><span class="p">(</span><span class="n">data</span><span class="p">),</span> <span class="n">fetch_list</span><span class="o">=</span><span class="n">outputs</span><span class="p">)</span> <span class="err"> acc1, acc5, loss = exe.run(pruned_program, feed=train_feeder.feed(data), fetch_list=outputs)</span>
<span class="nb">print</span><span class="p">(</span><span class="n">acc1</span><span class="p">,</span> <span class="n">acc5</span><span class="p">,</span> <span class="n">loss</span><span class="p">)</span> <span class="err"> print(acc1, acc5, loss)</span>
</pre></div> </pre></div>
</div> </div>
</div> </div>
......
...@@ -83,22 +83,22 @@ ...@@ -83,22 +83,22 @@
<ul class="current"> <ul class="current">
<li class="toctree-l1"><a class="reference internal" href="../index_en.html">English Documents</a></li> <li class="toctree-l1"><a class="reference internal" href="../index_en.html">English Documents</a></li>
<li class="toctree-l1"><a class="reference internal" href="../intro.html">PaddleSlim简介</a></li> <li class="toctree-l1"><a class="reference internal" href="../intro.html">介绍</a></li>
<li class="toctree-l1"><a class="reference internal" href="../install.html">安装</a></li> <li class="toctree-l1"><a class="reference internal" href="../install.html">安装</a></li>
<li class="toctree-l1 current"><a class="reference internal" href="index.html">快速开始</a><ul class="current"> <li class="toctree-l1 current"><a class="reference internal" href="index.html">快速开始</a><ul class="current">
<li class="toctree-l2"><a class="reference internal" href="pruning_tutorial.html">图像分类模型通道剪裁-快速开始</a></li> <li class="toctree-l2"><a class="reference internal" href="pruning_tutorial.html">图像分类模型通道剪裁-快速开始</a></li>
<li class="toctree-l2"><a class="reference internal" href="distillation_tutorial.html">图像分类模型知识蒸馏-快速开始</a></li> <li class="toctree-l2"><a class="reference internal" href="distillation_tutorial.html">图像分类模型知识蒸馏-快速开始</a></li>
<li class="toctree-l2 current"><a class="current reference internal" href="#">图像分类模型量化训练-快速开始</a><ul> <li class="toctree-l2 current"><a class="current reference internal" href="#">图像分类模型量化训练-快速开始</a><ul>
<li class="toctree-l3"><a class="reference internal" href="#id2">1. 导入依赖</a></li> <li class="toctree-l3"><a class="reference internal" href="#id3">1. 导入依赖</a></li>
<li class="toctree-l3"><a class="reference internal" href="#id3">2. 构建网络</a></li> <li class="toctree-l3"><a class="reference internal" href="#id4">2. 构建网络</a></li>
<li class="toctree-l3"><a class="reference internal" href="#id4">3. 训练模型</a><ul> <li class="toctree-l3"><a class="reference internal" href="#id5">3. 训练模型</a><ul>
<li class="toctree-l4"><a class="reference internal" href="#id5">3.1 定义输入数据</a></li> <li class="toctree-l4"><a class="reference internal" href="#id6">3.1 定义输入数据</a></li>
<li class="toctree-l4"><a class="reference internal" href="#id6">3.2 训练和测试</a></li> <li class="toctree-l4"><a class="reference internal" href="#id7">3.2 训练和测试</a></li>
</ul> </ul>
</li> </li>
<li class="toctree-l3"><a class="reference internal" href="#id7">4. 量化</a></li> <li class="toctree-l3"><a class="reference internal" href="#id8">4. 量化</a></li>
<li class="toctree-l3"><a class="reference internal" href="#id8">5. 训练和测试量化后的模型</a></li> <li class="toctree-l3"><a class="reference internal" href="#id10">5. 训练和测试量化后的模型</a></li>
<li class="toctree-l3"><a class="reference internal" href="#id9">6. 保存量化后的模型</a></li> <li class="toctree-l3"><a class="reference internal" href="#id11">6. 保存量化后的模型</a></li>
</ul> </ul>
</li> </li>
<li class="toctree-l2"><a class="reference internal" href="quant_post_tutorial.html">图像分类模型离线量化-快速开始</a></li> <li class="toctree-l2"><a class="reference internal" href="quant_post_tutorial.html">图像分类模型离线量化-快速开始</a></li>
...@@ -157,8 +157,8 @@ ...@@ -157,8 +157,8 @@
<div class="section" id="id1"> <div class="section" id="id1">
<h1>图像分类模型量化训练-快速开始<a class="headerlink" href="#id1" title="永久链接至标题"></a></h1> <h1>图像分类模型量化训练-快速开始<a class="headerlink" href="#id1" title="永久链接至标题"></a></h1>
<p>该教程以图像分类模型MobileNetV1为例,说明如何快速使用PaddleSlim的<a class="reference external" href="https://github.com/PaddlePaddle/PaddleSlim/blob/develop/docs/docs/api/quantization_api">量化训练接口</a>。 该示例包含以下步骤:</p> <p>该教程以图像分类模型MobileNetV1为例,说明如何快速使用PaddleSlim的<a class="reference external" href="https://github.com/PaddlePaddle/PaddleSlim/blob/develop/docs/docs/api/quantization_api.md">量化训练接口</a>。 该示例包含以下步骤:</p>
<ol class="simple"> <ol class="arabic simple">
<li>导入依赖</li> <li>导入依赖</li>
<li>构建模型</li> <li>构建模型</li>
<li>训练模型</li> <li>训练模型</li>
...@@ -166,8 +166,8 @@ ...@@ -166,8 +166,8 @@
<li>训练和测试量化后的模型</li> <li>训练和测试量化后的模型</li>
<li>保存量化后的模型</li> <li>保存量化后的模型</li>
</ol> </ol>
<div class="section" id="id2"> <div class="section" id="id3">
<h2>1. 导入依赖<a class="headerlink" href="#id2" title="永久链接至标题"></a></h2> <h2>1. 导入依赖<a class="headerlink" href="#id3" title="永久链接至标题"></a></h2>
<p>PaddleSlim依赖Paddle1.7版本,请确认已正确安装Paddle,然后按以下方式导入Paddle和PaddleSlim:</p> <p>PaddleSlim依赖Paddle1.7版本,请确认已正确安装Paddle,然后按以下方式导入Paddle和PaddleSlim:</p>
<div class="highlight-python"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">paddle</span> <div class="highlight-python"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">paddle</span>
<span class="kn">import</span> <span class="nn">paddle.fluid</span> <span class="k">as</span> <span class="nn">fluid</span> <span class="kn">import</span> <span class="nn">paddle.fluid</span> <span class="k">as</span> <span class="nn">fluid</span>
...@@ -176,8 +176,8 @@ ...@@ -176,8 +176,8 @@
</pre></div> </pre></div>
</div> </div>
</div> </div>
<div class="section" id="id3"> <div class="section" id="id4">
<h2>2. 构建网络<a class="headerlink" href="#id3" title="永久链接至标题"></a></h2> <h2>2. 构建网络<a class="headerlink" href="#id4" title="永久链接至标题"></a></h2>
<p>该章节构造一个用于对MNIST数据进行分类的分类模型,选用<code class="docutils literal"><span class="pre">MobileNetV1</span></code>,并将输入大小设置为<code class="docutils literal"><span class="pre">[1,</span> <span class="pre">28,</span> <span class="pre">28]</span></code>,输出类别数为10。 为了方便展示示例,我们在<code class="docutils literal"><span class="pre">paddleslim.models</span></code>下预定义了用于构建分类模型的方法,执行以下代码构建分类模型:</p> <p>该章节构造一个用于对MNIST数据进行分类的分类模型,选用<code class="docutils literal"><span class="pre">MobileNetV1</span></code>,并将输入大小设置为<code class="docutils literal"><span class="pre">[1,</span> <span class="pre">28,</span> <span class="pre">28]</span></code>,输出类别数为10。 为了方便展示示例,我们在<code class="docutils literal"><span class="pre">paddleslim.models</span></code>下预定义了用于构建分类模型的方法,执行以下代码构建分类模型:</p>
<blockquote> <blockquote>
<div>注意:paddleslim.models下的API并非PaddleSlim常规API,是为了简化示例而封装预定义的一系列方法,比如:模型结构的定义、Program的构建等。</div></blockquote> <div>注意:paddleslim.models下的API并非PaddleSlim常规API,是为了简化示例而封装预定义的一系列方法,比如:模型结构的定义、Program的构建等。</div></blockquote>
...@@ -186,11 +186,11 @@ ...@@ -186,11 +186,11 @@
</pre></div> </pre></div>
</div> </div>
</div> </div>
<div class="section" id="id4">
<h2>3. 训练模型<a class="headerlink" href="#id4" title="永久链接至标题"></a></h2>
<p>该章节介绍了如何定义输入数据和如何训练和测试分类模型。先训练分类模型的原因是量化训练过程是在训练好的模型上进行的,也就是说是在训练好的模型的基础上加入量化反量化op之后,用小学习率进行参数微调。</p>
<div class="section" id="id5"> <div class="section" id="id5">
<h3>3.1 定义输入数据<a class="headerlink" href="#id5" title="永久链接至标题"></a></h3> <h2>3. 训练模型<a class="headerlink" href="#id5" title="永久链接至标题"></a></h2>
<p>该章节介绍了如何定义输入数据和如何训练和测试分类模型。先训练分类模型的原因是量化训练过程是在训练好的模型上进行的,也就是说是在训练好的模型的基础上加入量化反量化op之后,用小学习率进行参数微调。</p>
<div class="section" id="id6">
<h3>3.1 定义输入数据<a class="headerlink" href="#id6" title="永久链接至标题"></a></h3>
<p>为了快速执行该示例,我们选取简单的MNIST数据,Paddle框架的<code class="docutils literal"><span class="pre">paddle.dataset.mnist</span></code>包定义了MNIST数据的下载和读取。 <p>为了快速执行该示例,我们选取简单的MNIST数据,Paddle框架的<code class="docutils literal"><span class="pre">paddle.dataset.mnist</span></code>包定义了MNIST数据的下载和读取。
代码如下:</p> 代码如下:</p>
<div class="highlight-python"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">paddle.dataset.mnist</span> <span class="k">as</span> <span class="nn">reader</span> <div class="highlight-python"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">paddle.dataset.mnist</span> <span class="k">as</span> <span class="nn">reader</span>
...@@ -202,8 +202,8 @@ ...@@ -202,8 +202,8 @@
</pre></div> </pre></div>
</div> </div>
</div> </div>
<div class="section" id="id6"> <div class="section" id="id7">
<h3>3.2 训练和测试<a class="headerlink" href="#id6" title="永久链接至标题"></a></h3> <h3>3.2 训练和测试<a class="headerlink" href="#id7" title="永久链接至标题"></a></h3>
<p>先定义训练和测试函数,正常训练和量化训练时只需要调用函数即可。在训练函数中执行了一个epoch的训练,因为MNIST数据集数据较少,一个epoch就可将top1精度训练到95%以上。</p> <p>先定义训练和测试函数,正常训练和量化训练时只需要调用函数即可。在训练函数中执行了一个epoch的训练,因为MNIST数据集数据较少,一个epoch就可将top1精度训练到95%以上。</p>
<div class="highlight-python"><div class="highlight"><pre><span></span><span class="k">def</span> <span class="nf">train</span><span class="p">(</span><span class="n">prog</span><span class="p">):</span> <div class="highlight-python"><div class="highlight"><pre><span></span><span class="k">def</span> <span class="nf">train</span><span class="p">(</span><span class="n">prog</span><span class="p">):</span>
<span class="nb">iter</span> <span class="o">=</span> <span class="mi">0</span> <span class="nb">iter</span> <span class="o">=</span> <span class="mi">0</span>
...@@ -236,16 +236,16 @@ ...@@ -236,16 +236,16 @@
</div> </div>
</div> </div>
</div> </div>
<div class="section" id="id7"> <div class="section" id="id8">
<h2>4. 量化<a class="headerlink" href="#id7" title="永久链接至标题"></a></h2> <h2>4. 量化<a class="headerlink" href="#id8" title="永久链接至标题"></a></h2>
<p>按照<a class="reference external" href="https://paddlepaddle.github.io/PaddleSlim/api/quantization_api/#_1">默认配置</a><code class="docutils literal"><span class="pre">train_program</span></code><code class="docutils literal"><span class="pre">val_program</span></code>中加入量化和反量化op.</p> <p>按照<a class="reference external" href="https://paddlepaddle.github.io/PaddleSlim/api/quantization_api/#_1">默认配置</a><code class="docutils literal"><span class="pre">train_program</span></code><code class="docutils literal"><span class="pre">val_program</span></code>中加入量化和反量化op.</p>
<div class="highlight-python"><div class="highlight"><pre><span></span><span class="n">quant_program</span> <span class="o">=</span> <span class="n">slim</span><span class="o">.</span><span class="n">quant</span><span class="o">.</span><span class="n">quant_aware</span><span class="p">(</span><span class="n">train_program</span><span class="p">,</span> <span class="n">exe</span><span class="o">.</span><span class="n">place</span><span class="p">,</span> <span class="n">for_test</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span> <div class="highlight-python"><div class="highlight"><pre><span></span><span class="n">quant_program</span> <span class="o">=</span> <span class="n">slim</span><span class="o">.</span><span class="n">quant</span><span class="o">.</span><span class="n">quant_aware</span><span class="p">(</span><span class="n">train_program</span><span class="p">,</span> <span class="n">exe</span><span class="o">.</span><span class="n">place</span><span class="p">,</span> <span class="n">for_test</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span>
<span class="n">val_quant_program</span> <span class="o">=</span> <span class="n">slim</span><span class="o">.</span><span class="n">quant</span><span class="o">.</span><span class="n">quant_aware</span><span class="p">(</span><span class="n">val_program</span><span class="p">,</span> <span class="n">exe</span><span class="o">.</span><span class="n">place</span><span class="p">,</span> <span class="n">for_test</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> <span class="n">val_quant_program</span> <span class="o">=</span> <span class="n">slim</span><span class="o">.</span><span class="n">quant</span><span class="o">.</span><span class="n">quant_aware</span><span class="p">(</span><span class="n">val_program</span><span class="p">,</span> <span class="n">exe</span><span class="o">.</span><span class="n">place</span><span class="p">,</span> <span class="n">for_test</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span>
</pre></div> </pre></div>
</div> </div>
</div> </div>
<div class="section" id="id8"> <div class="section" id="id10">
<h2>5. 训练和测试量化后的模型<a class="headerlink" href="#id8" title="永久链接至标题"></a></h2> <h2>5. 训练和测试量化后的模型<a class="headerlink" href="#id10" title="永久链接至标题"></a></h2>
<p>微调量化后的模型,训练一个epoch后测试。</p> <p>微调量化后的模型,训练一个epoch后测试。</p>
<div class="highlight-python"><div class="highlight"><pre><span></span><span class="n">train</span><span class="p">(</span><span class="n">quant_program</span><span class="p">)</span> <div class="highlight-python"><div class="highlight"><pre><span></span><span class="n">train</span><span class="p">(</span><span class="n">quant_program</span><span class="p">)</span>
</pre></div> </pre></div>
...@@ -255,8 +255,8 @@ ...@@ -255,8 +255,8 @@
</pre></div> </pre></div>
</div> </div>
</div> </div>
<div class="section" id="id9"> <div class="section" id="id11">
<h2>6. 保存量化后的模型<a class="headerlink" href="#id9" title="永久链接至标题"></a></h2> <h2>6. 保存量化后的模型<a class="headerlink" href="#id11" title="永久链接至标题"></a></h2>
<p><code class="docutils literal"><span class="pre">4.</span> <span class="pre">量化</span></code>中使用接口<code class="docutils literal"><span class="pre">slim.quant.quant_aware</span></code>接口得到的模型只适合训练时使用,为了得到最终使用时的模型,需要使用<a class="reference external" href="https://paddlepaddle.github.io/PaddleSlim/api/quantization_api/#convert">slim.quant.convert</a>接口,然后使用<a class="reference external" href="https://www.paddlepaddle.org.cn/documentation/docs/zh/develop/api_cn/io_cn/save_inference_model_cn.html#save-inference-model">fluid.io.save_inference_model</a>保存模型。<code class="docutils literal"><span class="pre">float_prog</span></code>的参数数据类型是float32,但是数据范围是int8, 保存之后可使用fluid或者paddle-lite加载使用,paddle-lite在使用时,会先将类型转换为int8。<code class="docutils literal"><span class="pre">int8_prog</span></code>的参数数据类型是int8, 保存后可看到量化后模型大小,不可加载使用。</p> <p><code class="docutils literal"><span class="pre">4.</span> <span class="pre">量化</span></code>中使用接口<code class="docutils literal"><span class="pre">slim.quant.quant_aware</span></code>接口得到的模型只适合训练时使用,为了得到最终使用时的模型,需要使用<a class="reference external" href="https://paddlepaddle.github.io/PaddleSlim/api/quantization_api/#convert">slim.quant.convert</a>接口,然后使用<a class="reference external" href="https://www.paddlepaddle.org.cn/documentation/docs/zh/develop/api_cn/io_cn/save_inference_model_cn.html#save-inference-model">fluid.io.save_inference_model</a>保存模型。<code class="docutils literal"><span class="pre">float_prog</span></code>的参数数据类型是float32,但是数据范围是int8, 保存之后可使用fluid或者paddle-lite加载使用,paddle-lite在使用时,会先将类型转换为int8。<code class="docutils literal"><span class="pre">int8_prog</span></code>的参数数据类型是int8, 保存后可看到量化后模型大小,不可加载使用。</p>
<div class="highlight-python"><div class="highlight"><pre><span></span><span class="n">float_prog</span><span class="p">,</span> <span class="n">int8_prog</span> <span class="o">=</span> <span class="n">slim</span><span class="o">.</span><span class="n">quant</span><span class="o">.</span><span class="n">convert</span><span class="p">(</span><span class="n">val_quant_program</span><span class="p">,</span> <span class="n">exe</span><span class="o">.</span><span class="n">place</span><span class="p">,</span> <span class="n">save_int8</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> <div class="highlight-python"><div class="highlight"><pre><span></span><span class="n">float_prog</span><span class="p">,</span> <span class="n">int8_prog</span> <span class="o">=</span> <span class="n">slim</span><span class="o">.</span><span class="n">quant</span><span class="o">.</span><span class="n">convert</span><span class="p">(</span><span class="n">val_quant_program</span><span class="p">,</span> <span class="n">exe</span><span class="o">.</span><span class="n">place</span><span class="p">,</span> <span class="n">save_int8</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span>
<span class="n">target_vars</span> <span class="o">=</span> <span class="p">[</span><span class="n">float_prog</span><span class="o">.</span><span class="n">global_block</span><span class="p">()</span><span class="o">.</span><span class="n">var</span><span class="p">(</span><span class="n">name</span><span class="p">)</span> <span class="k">for</span> <span class="n">name</span> <span class="ow">in</span> <span class="n">outputs</span><span class="p">]</span> <span class="n">target_vars</span> <span class="o">=</span> <span class="p">[</span><span class="n">float_prog</span><span class="o">.</span><span class="n">global_block</span><span class="p">()</span><span class="o">.</span><span class="n">var</span><span class="p">(</span><span class="n">name</span><span class="p">)</span> <span class="k">for</span> <span class="n">name</span> <span class="ow">in</span> <span class="n">outputs</span><span class="p">]</span>
......
...@@ -155,8 +155,8 @@ ...@@ -155,8 +155,8 @@
<div class="section" id="training-aware-quantization-of-image-classification-model-quick-start"> <div class="section" id="training-aware-quantization-of-image-classification-model-quick-start">
<h1>Training-aware Quantization of image classification model - quick start<a class="headerlink" href="#training-aware-quantization-of-image-classification-model-quick-start" title="Permalink to this headline"></a></h1> <h1>Training-aware Quantization of image classification model - quick start<a class="headerlink" href="#training-aware-quantization-of-image-classification-model-quick-start" title="Permalink to this headline"></a></h1>
<p>This tutorial shows how to do training-aware quantization using <a class="reference external" href="https://github.com/PaddlePaddle/PaddleSlim/blob/develop/docs/docs/api/quantization_api">API</a> in PaddleSlim. We use MobileNetV1 to train image classification model as example. The tutorial contains follow sections:</p> <p>This tutorial shows how to do training-aware quantization using <a class="reference external" href="https://github.com/PaddlePaddle/PaddleSlim/blob/develop/docs/docs/api/quantization_api.md">API</a> in PaddleSlim. We use MobileNetV1 to train image classification model as example. The tutorial contains follow sections:</p>
<ol class="simple"> <ol class="arabic simple">
<li>Necessary imports</li> <li>Necessary imports</li>
<li>Model architecture</li> <li>Model architecture</li>
<li>Train normal model</li> <li>Train normal model</li>
...@@ -176,7 +176,7 @@ ...@@ -176,7 +176,7 @@
</div> </div>
<div class="section" id="model-architecture"> <div class="section" id="model-architecture">
<h2>2. Model architecture<a class="headerlink" href="#model-architecture" title="Permalink to this headline"></a></h2> <h2>2. Model architecture<a class="headerlink" href="#model-architecture" title="Permalink to this headline"></a></h2>
<p>The section constructs a classification model, which use <code class="docutils literal"><span class="pre">MobileNetV1</span></code> and MNIST dataset. The model&#8216;s input size is <code class="docutils literal"><span class="pre">[1,</span> <span class="pre">28,</span> <span class="pre">28]</span></code> and output size is 10. In order to show tutorial conveniently, we pre-defined a method to get image classification model in <code class="docutils literal"><span class="pre">paddleslim.models</span></code>.</p> <p>The section constructs a classification model, which use <code class="docutils literal"><span class="pre">MobileNetV1</span></code> and MNIST dataset. The model&#8217;s input size is <code class="docutils literal"><span class="pre">[1,</span> <span class="pre">28,</span> <span class="pre">28]</span></code> and output size is 10. In order to show tutorial conveniently, we pre-defined a method to get image classification model in <code class="docutils literal"><span class="pre">paddleslim.models</span></code>.</p>
<blockquote> <blockquote>
<div>note: The APIs in <code class="docutils literal"><span class="pre">paddleslim.models</span></code> are not formal inferface in PaddleSlim. They are defined to simplify the tutorial such as the definition of model structure and the construction of Program.</div></blockquote> <div>note: The APIs in <code class="docutils literal"><span class="pre">paddleslim.models</span></code> are not formal inferface in PaddleSlim. They are defined to simplify the tutorial such as the definition of model structure and the construction of Program.</div></blockquote>
<div class="highlight-python"><div class="highlight"><pre><span></span><span class="n">exe</span><span class="p">,</span> <span class="n">train_program</span><span class="p">,</span> <span class="n">val_program</span><span class="p">,</span> <span class="n">inputs</span><span class="p">,</span> <span class="n">outputs</span> <span class="o">=</span> \ <div class="highlight-python"><div class="highlight"><pre><span></span><span class="n">exe</span><span class="p">,</span> <span class="n">train_program</span><span class="p">,</span> <span class="n">val_program</span><span class="p">,</span> <span class="n">inputs</span><span class="p">,</span> <span class="n">outputs</span> <span class="o">=</span> \
...@@ -186,7 +186,7 @@ ...@@ -186,7 +186,7 @@
</div> </div>
<div class="section" id="train-normal-model"> <div class="section" id="train-normal-model">
<h2>3. Train normal model<a class="headerlink" href="#train-normal-model" title="Permalink to this headline"></a></h2> <h2>3. Train normal model<a class="headerlink" href="#train-normal-model" title="Permalink to this headline"></a></h2>
<p>The section shows how to define model inputs, train and test model. The reason for training the normal image classification model first is that the quantization model&#8216;s training process is performed on the well-trained model. We add quantization and dequantization operators in well-trained model and finetune using smaller learning rate.</p> <p>The section shows how to define model inputs, train and test model. The reason for training the normal image classification model first is that the quantization model&#8217;s training process is performed on the well-trained model. We add quantization and dequantization operators in well-trained model and finetune using smaller learning rate.</p>
<div class="section" id="input-data-definition"> <div class="section" id="input-data-definition">
<h3>3.1 input data definition<a class="headerlink" href="#input-data-definition" title="Permalink to this headline"></a></h3> <h3>3.1 input data definition<a class="headerlink" href="#input-data-definition" title="Permalink to this headline"></a></h3>
<p>To speed up training process, we select MNIST dataset to train image classification model. The API <code class="docutils literal"><span class="pre">paddle.dataset.mnist</span></code> in Paddle framework contains downloading and reading the images in dataset.</p> <p>To speed up training process, we select MNIST dataset to train image classification model. The API <code class="docutils literal"><span class="pre">paddle.dataset.mnist</span></code> in Paddle framework contains downloading and reading the images in dataset.</p>
...@@ -254,7 +254,7 @@ ...@@ -254,7 +254,7 @@
</div> </div>
<div class="section" id="save-model-after-quantization"> <div class="section" id="save-model-after-quantization">
<h2>6. Save model after quantization<a class="headerlink" href="#save-model-after-quantization" title="Permalink to this headline"></a></h2> <h2>6. Save model after quantization<a class="headerlink" href="#save-model-after-quantization" title="Permalink to this headline"></a></h2>
<p>The model in <code class="docutils literal"><span class="pre">4.</span> <span class="pre">Quantization</span></code> after calling <code class="docutils literal"><span class="pre">slim.quant.quant_aware</span></code> API is only suitable to train. To get the inference model, we should use <a class="reference external" href="https://paddlepaddle.github.io/PaddleSlim/api/quantization_api/#convert">slim.quant.convert</a> API to change model architecture and use <a class="reference external" href="https://www.paddlepaddle.org.cn/documentation/docs/zh/develop/api_cn/io_cn/save_inference_model_cn.html#save-inference-model">fluid.io.save_inference_model</a> to save model. <code class="docutils literal"><span class="pre">float_prog</span></code>&#8216;s parameters are float32 dtype but in int8&#8216;s range which can be used in <code class="docutils literal"><span class="pre">fluid</span></code> or <code class="docutils literal"><span class="pre">paddle-lite</span></code>. <code class="docutils literal"><span class="pre">paddle-lite</span></code> will change the parameters&#8216; dtype from float32 to int8 first when loading the inference model. <code class="docutils literal"><span class="pre">int8_prog</span></code>&#8216;s parameters are int8 dtype and we can get model size after quantization by saving it. <code class="docutils literal"><span class="pre">int8_prog</span></code> cannot be used in <code class="docutils literal"><span class="pre">fluid</span></code> or <code class="docutils literal"><span class="pre">paddle-lite</span></code>.</p> <p>The model in <code class="docutils literal"><span class="pre">4.</span> <span class="pre">Quantization</span></code> after calling <code class="docutils literal"><span class="pre">slim.quant.quant_aware</span></code> API is only suitable to train. To get the inference model, we should use <a class="reference external" href="https://paddlepaddle.github.io/PaddleSlim/api/quantization_api/#convert">slim.quant.convert</a> API to change model architecture and use <a class="reference external" href="https://www.paddlepaddle.org.cn/documentation/docs/zh/develop/api_cn/io_cn/save_inference_model_cn.html#save-inference-model">fluid.io.save_inference_model</a> to save model. <code class="docutils literal"><span class="pre">float_prog</span></code>&#8216;s parameters are float32 dtype but in int8&#8217;s range which can be used in <code class="docutils literal"><span class="pre">fluid</span></code> or <code class="docutils literal"><span class="pre">paddle-lite</span></code>. <code class="docutils literal"><span class="pre">paddle-lite</span></code> will change the parameters&#8217; dtype from float32 to int8 first when loading the inference model. <code class="docutils literal"><span class="pre">int8_prog</span></code>&#8216;s parameters are int8 dtype and we can get model size after quantization by saving it. <code class="docutils literal"><span class="pre">int8_prog</span></code> cannot be used in <code class="docutils literal"><span class="pre">fluid</span></code> or <code class="docutils literal"><span class="pre">paddle-lite</span></code>.</p>
<div class="highlight-python"><div class="highlight"><pre><span></span><span class="n">float_prog</span><span class="p">,</span> <span class="n">int8_prog</span> <span class="o">=</span> <span class="n">slim</span><span class="o">.</span><span class="n">quant</span><span class="o">.</span><span class="n">convert</span><span class="p">(</span><span class="n">val_quant_program</span><span class="p">,</span> <span class="n">exe</span><span class="o">.</span><span class="n">place</span><span class="p">,</span> <span class="n">save_int8</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> <div class="highlight-python"><div class="highlight"><pre><span></span><span class="n">float_prog</span><span class="p">,</span> <span class="n">int8_prog</span> <span class="o">=</span> <span class="n">slim</span><span class="o">.</span><span class="n">quant</span><span class="o">.</span><span class="n">convert</span><span class="p">(</span><span class="n">val_quant_program</span><span class="p">,</span> <span class="n">exe</span><span class="o">.</span><span class="n">place</span><span class="p">,</span> <span class="n">save_int8</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span>
<span class="n">target_vars</span> <span class="o">=</span> <span class="p">[</span><span class="n">float_prog</span><span class="o">.</span><span class="n">global_block</span><span class="p">()</span><span class="o">.</span><span class="n">var</span><span class="p">(</span><span class="n">name</span><span class="p">)</span> <span class="k">for</span> <span class="n">name</span> <span class="ow">in</span> <span class="n">outputs</span><span class="p">]</span> <span class="n">target_vars</span> <span class="o">=</span> <span class="p">[</span><span class="n">float_prog</span><span class="o">.</span><span class="n">global_block</span><span class="p">()</span><span class="o">.</span><span class="n">var</span><span class="p">(</span><span class="n">name</span><span class="p">)</span> <span class="k">for</span> <span class="n">name</span> <span class="ow">in</span> <span class="n">outputs</span><span class="p">]</span>
<span class="n">fluid</span><span class="o">.</span><span class="n">io</span><span class="o">.</span><span class="n">save_inference_model</span><span class="p">(</span><span class="n">dirname</span><span class="o">=</span><span class="s1">&#39;./inference_model/float&#39;</span><span class="p">,</span> <span class="n">fluid</span><span class="o">.</span><span class="n">io</span><span class="o">.</span><span class="n">save_inference_model</span><span class="p">(</span><span class="n">dirname</span><span class="o">=</span><span class="s1">&#39;./inference_model/float&#39;</span><span class="p">,</span>
......
...@@ -83,21 +83,21 @@ ...@@ -83,21 +83,21 @@
<ul class="current"> <ul class="current">
<li class="toctree-l1"><a class="reference internal" href="../index_en.html">English Documents</a></li> <li class="toctree-l1"><a class="reference internal" href="../index_en.html">English Documents</a></li>
<li class="toctree-l1"><a class="reference internal" href="../intro.html">PaddleSlim简介</a></li> <li class="toctree-l1"><a class="reference internal" href="../intro.html">介绍</a></li>
<li class="toctree-l1"><a class="reference internal" href="../install.html">安装</a></li> <li class="toctree-l1"><a class="reference internal" href="../install.html">安装</a></li>
<li class="toctree-l1 current"><a class="reference internal" href="index.html">快速开始</a><ul class="current"> <li class="toctree-l1 current"><a class="reference internal" href="index.html">快速开始</a><ul class="current">
<li class="toctree-l2"><a class="reference internal" href="pruning_tutorial.html">图像分类模型通道剪裁-快速开始</a></li> <li class="toctree-l2"><a class="reference internal" href="pruning_tutorial.html">图像分类模型通道剪裁-快速开始</a></li>
<li class="toctree-l2"><a class="reference internal" href="distillation_tutorial.html">图像分类模型知识蒸馏-快速开始</a></li> <li class="toctree-l2"><a class="reference internal" href="distillation_tutorial.html">图像分类模型知识蒸馏-快速开始</a></li>
<li class="toctree-l2"><a class="reference internal" href="quant_aware_tutorial.html">图像分类模型量化训练-快速开始</a></li> <li class="toctree-l2"><a class="reference internal" href="quant_aware_tutorial.html">图像分类模型量化训练-快速开始</a></li>
<li class="toctree-l2 current"><a class="current reference internal" href="#">图像分类模型离线量化-快速开始</a><ul> <li class="toctree-l2 current"><a class="current reference internal" href="#">图像分类模型离线量化-快速开始</a><ul>
<li class="toctree-l3"><a class="reference internal" href="#id2">1. 导入依赖</a></li> <li class="toctree-l3"><a class="reference internal" href="#id3">1. 导入依赖</a></li>
<li class="toctree-l3"><a class="reference internal" href="#id3">2. 构建网络</a></li> <li class="toctree-l3"><a class="reference internal" href="#id4">2. 构建网络</a></li>
<li class="toctree-l3"><a class="reference internal" href="#id4">3. 训练模型</a><ul> <li class="toctree-l3"><a class="reference internal" href="#id5">3. 训练模型</a><ul>
<li class="toctree-l4"><a class="reference internal" href="#id5">3.1 定义输入数据</a></li> <li class="toctree-l4"><a class="reference internal" href="#id6">3.1 定义输入数据</a></li>
<li class="toctree-l4"><a class="reference internal" href="#id6">3.2 训练和测试</a></li> <li class="toctree-l4"><a class="reference internal" href="#id7">3.2 训练和测试</a></li>
</ul> </ul>
</li> </li>
<li class="toctree-l3"><a class="reference internal" href="#id7">4. 离线量化</a></li> <li class="toctree-l3"><a class="reference internal" href="#id8">4. 离线量化</a></li>
</ul> </ul>
</li> </li>
<li class="toctree-l2"><a class="reference internal" href="nas_tutorial.html">图像分类网络结构搜索-快速开始</a></li> <li class="toctree-l2"><a class="reference internal" href="nas_tutorial.html">图像分类网络结构搜索-快速开始</a></li>
...@@ -155,15 +155,15 @@ ...@@ -155,15 +155,15 @@
<div class="section" id="id1"> <div class="section" id="id1">
<h1>图像分类模型离线量化-快速开始<a class="headerlink" href="#id1" title="永久链接至标题"></a></h1> <h1>图像分类模型离线量化-快速开始<a class="headerlink" href="#id1" title="永久链接至标题"></a></h1>
<p>该教程以图像分类模型MobileNetV1为例,说明如何快速使用PaddleSlim的<a class="reference external" href="https://github.com/PaddlePaddle/PaddleSlim/blob/develop/docs/docs/api/quantization_api">离线量化接口</a>。 该示例包含以下步骤:</p> <p>该教程以图像分类模型MobileNetV1为例,说明如何快速使用PaddleSlim的<a class="reference external" href="https://github.com/PaddlePaddle/PaddleSlim/blob/develop/docs/docs/api/quantization_api.md">离线量化接口</a>。 该示例包含以下步骤:</p>
<ol class="simple"> <ol class="arabic simple">
<li>导入依赖</li> <li>导入依赖</li>
<li>构建模型</li> <li>构建模型</li>
<li>训练模型</li> <li>训练模型</li>
<li>离线量化</li> <li>离线量化</li>
</ol> </ol>
<div class="section" id="id2"> <div class="section" id="id3">
<h2>1. 导入依赖<a class="headerlink" href="#id2" title="永久链接至标题"></a></h2> <h2>1. 导入依赖<a class="headerlink" href="#id3" title="永久链接至标题"></a></h2>
<p>PaddleSlim依赖Paddle1.7版本,请确认已正确安装Paddle,然后按以下方式导入Paddle和PaddleSlim:</p> <p>PaddleSlim依赖Paddle1.7版本,请确认已正确安装Paddle,然后按以下方式导入Paddle和PaddleSlim:</p>
<div class="highlight-python"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">paddle</span> <div class="highlight-python"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">paddle</span>
<span class="kn">import</span> <span class="nn">paddle.fluid</span> <span class="k">as</span> <span class="nn">fluid</span> <span class="kn">import</span> <span class="nn">paddle.fluid</span> <span class="k">as</span> <span class="nn">fluid</span>
...@@ -172,8 +172,8 @@ ...@@ -172,8 +172,8 @@
</pre></div> </pre></div>
</div> </div>
</div> </div>
<div class="section" id="id3"> <div class="section" id="id4">
<h2>2. 构建网络<a class="headerlink" href="#id3" title="永久链接至标题"></a></h2> <h2>2. 构建网络<a class="headerlink" href="#id4" title="永久链接至标题"></a></h2>
<p>该章节构造一个用于对MNIST数据进行分类的分类模型,选用<code class="docutils literal"><span class="pre">MobileNetV1</span></code>,并将输入大小设置为<code class="docutils literal"><span class="pre">[1,</span> <span class="pre">28,</span> <span class="pre">28]</span></code>,输出类别数为10。 为了方便展示示例,我们在<code class="docutils literal"><span class="pre">paddleslim.models</span></code>下预定义了用于构建分类模型的方法,执行以下代码构建分类模型:</p> <p>该章节构造一个用于对MNIST数据进行分类的分类模型,选用<code class="docutils literal"><span class="pre">MobileNetV1</span></code>,并将输入大小设置为<code class="docutils literal"><span class="pre">[1,</span> <span class="pre">28,</span> <span class="pre">28]</span></code>,输出类别数为10。 为了方便展示示例,我们在<code class="docutils literal"><span class="pre">paddleslim.models</span></code>下预定义了用于构建分类模型的方法,执行以下代码构建分类模型:</p>
<blockquote> <blockquote>
<div>注意:paddleslim.models下的API并非PaddleSlim常规API,是为了简化示例而封装预定义的一系列方法,比如:模型结构的定义、Program的构建等。</div></blockquote> <div>注意:paddleslim.models下的API并非PaddleSlim常规API,是为了简化示例而封装预定义的一系列方法,比如:模型结构的定义、Program的构建等。</div></blockquote>
...@@ -182,11 +182,11 @@ ...@@ -182,11 +182,11 @@
</pre></div> </pre></div>
</div> </div>
</div> </div>
<div class="section" id="id4">
<h2>3. 训练模型<a class="headerlink" href="#id4" title="永久链接至标题"></a></h2>
<p>该章节介绍了如何定义输入数据和如何训练和测试分类模型。先训练分类模型的原因是离线量化需要一个训练好的模型。</p>
<div class="section" id="id5"> <div class="section" id="id5">
<h3>3.1 定义输入数据<a class="headerlink" href="#id5" title="永久链接至标题"></a></h3> <h2>3. 训练模型<a class="headerlink" href="#id5" title="永久链接至标题"></a></h2>
<p>该章节介绍了如何定义输入数据和如何训练和测试分类模型。先训练分类模型的原因是离线量化需要一个训练好的模型。</p>
<div class="section" id="id6">
<h3>3.1 定义输入数据<a class="headerlink" href="#id6" title="永久链接至标题"></a></h3>
<p>为了快速执行该示例,我们选取简单的MNIST数据,Paddle框架的<code class="docutils literal"><span class="pre">paddle.dataset.mnist</span></code>包定义了MNIST数据的下载和读取。 <p>为了快速执行该示例,我们选取简单的MNIST数据,Paddle框架的<code class="docutils literal"><span class="pre">paddle.dataset.mnist</span></code>包定义了MNIST数据的下载和读取。
代码如下:</p> 代码如下:</p>
<div class="highlight-python"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">paddle.dataset.mnist</span> <span class="k">as</span> <span class="nn">reader</span> <div class="highlight-python"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">paddle.dataset.mnist</span> <span class="k">as</span> <span class="nn">reader</span>
...@@ -198,8 +198,8 @@ ...@@ -198,8 +198,8 @@
</pre></div> </pre></div>
</div> </div>
</div> </div>
<div class="section" id="id6"> <div class="section" id="id7">
<h3>3.2 训练和测试<a class="headerlink" href="#id6" title="永久链接至标题"></a></h3> <h3>3.2 训练和测试<a class="headerlink" href="#id7" title="永久链接至标题"></a></h3>
<p>先定义训练和测试函数。在训练函数中执行了一个epoch的训练,因为MNIST数据集数据较少,一个epoch就可将top1精度训练到95%以上。</p> <p>先定义训练和测试函数。在训练函数中执行了一个epoch的训练,因为MNIST数据集数据较少,一个epoch就可将top1精度训练到95%以上。</p>
<div class="highlight-python"><div class="highlight"><pre><span></span><span class="k">def</span> <span class="nf">train</span><span class="p">(</span><span class="n">prog</span><span class="p">):</span> <div class="highlight-python"><div class="highlight"><pre><span></span><span class="k">def</span> <span class="nf">train</span><span class="p">(</span><span class="n">prog</span><span class="p">):</span>
<span class="nb">iter</span> <span class="o">=</span> <span class="mi">0</span> <span class="nb">iter</span> <span class="o">=</span> <span class="mi">0</span>
...@@ -241,8 +241,8 @@ ...@@ -241,8 +241,8 @@
</div> </div>
</div> </div>
</div> </div>
<div class="section" id="id7"> <div class="section" id="id8">
<h2>4. 离线量化<a class="headerlink" href="#id7" title="永久链接至标题"></a></h2> <h2>4. 离线量化<a class="headerlink" href="#id8" title="永久链接至标题"></a></h2>
<p>调用离线量化接口,加载文件夹<code class="docutils literal"><span class="pre">'./inference_model'</span></code>训练好的分类模型,并使用10个batch的数据进行参数校正。此过程无需训练,只需跑前向过程来计算量化所需参数。离线量化后的模型保存在文件夹<code class="docutils literal"><span class="pre">'./quant_post_model'</span></code>下。</p> <p>调用离线量化接口,加载文件夹<code class="docutils literal"><span class="pre">'./inference_model'</span></code>训练好的分类模型,并使用10个batch的数据进行参数校正。此过程无需训练,只需跑前向过程来计算量化所需参数。离线量化后的模型保存在文件夹<code class="docutils literal"><span class="pre">'./quant_post_model'</span></code>下。</p>
<div class="highlight-python"><div class="highlight"><pre><span></span><span class="n">slim</span><span class="o">.</span><span class="n">quant</span><span class="o">.</span><span class="n">quant_post</span><span class="p">(</span> <div class="highlight-python"><div class="highlight"><pre><span></span><span class="n">slim</span><span class="o">.</span><span class="n">quant</span><span class="o">.</span><span class="n">quant_post</span><span class="p">(</span>
<span class="n">executor</span><span class="o">=</span><span class="n">exe</span><span class="p">,</span> <span class="n">executor</span><span class="o">=</span><span class="n">exe</span><span class="p">,</span>
......
...@@ -153,8 +153,8 @@ ...@@ -153,8 +153,8 @@
<div class="section" id="post-training-quantization-of-image-classification-model-quick-start"> <div class="section" id="post-training-quantization-of-image-classification-model-quick-start">
<h1>Post-training Quantization of image classification model - quick start<a class="headerlink" href="#post-training-quantization-of-image-classification-model-quick-start" title="Permalink to this headline"></a></h1> <h1>Post-training Quantization of image classification model - quick start<a class="headerlink" href="#post-training-quantization-of-image-classification-model-quick-start" title="Permalink to this headline"></a></h1>
<p>This tutorial shows how to do post training quantization using <a class="reference external" href="https://github.com/PaddlePaddle/PaddleSlim/blob/develop/docs/docs/api/quantization_api">API</a> in PaddleSlim. We use MobileNetV1 to train image classification model as example. The tutorial contains follow sections:</p> <p>This tutorial shows how to do post training quantization using <a class="reference external" href="https://github.com/PaddlePaddle/PaddleSlim/blob/develop/docs/docs/api/quantization_api.md">API</a> in PaddleSlim. We use MobileNetV1 to train image classification model as example. The tutorial contains follow sections:</p>
<ol class="simple"> <ol class="arabic simple">
<li>Necessary imports</li> <li>Necessary imports</li>
<li>Model architecture</li> <li>Model architecture</li>
<li>Train normal model</li> <li>Train normal model</li>
...@@ -172,7 +172,7 @@ ...@@ -172,7 +172,7 @@
</div> </div>
<div class="section" id="model-architecture"> <div class="section" id="model-architecture">
<h2>2. Model architecture<a class="headerlink" href="#model-architecture" title="Permalink to this headline"></a></h2> <h2>2. Model architecture<a class="headerlink" href="#model-architecture" title="Permalink to this headline"></a></h2>
<p>The section constructs a classification model, which use <code class="docutils literal"><span class="pre">MobileNetV1</span></code> and MNIST dataset. The model&#8216;s input size is <code class="docutils literal"><span class="pre">[1,</span> <span class="pre">28,</span> <span class="pre">28]</span></code> and output size is 10. In order to show tutorial conveniently, we pre-defined a method to get image classification model in <code class="docutils literal"><span class="pre">paddleslim.models</span></code>.</p> <p>The section constructs a classification model, which use <code class="docutils literal"><span class="pre">MobileNetV1</span></code> and MNIST dataset. The model&#8217;s input size is <code class="docutils literal"><span class="pre">[1,</span> <span class="pre">28,</span> <span class="pre">28]</span></code> and output size is 10. In order to show tutorial conveniently, we pre-defined a method to get image classification model in <code class="docutils literal"><span class="pre">paddleslim.models</span></code>.</p>
<blockquote> <blockquote>
<div>note: The APIs in <code class="docutils literal"><span class="pre">paddleslim.models</span></code> are not formal inferface in PaddleSlim. They are defined to simplify the tutorial such as the definition of model structure and the construction of Program.</div></blockquote> <div>note: The APIs in <code class="docutils literal"><span class="pre">paddleslim.models</span></code> are not formal inferface in PaddleSlim. They are defined to simplify the tutorial such as the definition of model structure and the construction of Program.</div></blockquote>
<div class="highlight-python"><div class="highlight"><pre><span></span><span class="n">exe</span><span class="p">,</span> <span class="n">train_program</span><span class="p">,</span> <span class="n">val_program</span><span class="p">,</span> <span class="n">inputs</span><span class="p">,</span> <span class="n">outputs</span> <span class="o">=</span> \ <div class="highlight-python"><div class="highlight"><pre><span></span><span class="n">exe</span><span class="p">,</span> <span class="n">train_program</span><span class="p">,</span> <span class="n">val_program</span><span class="p">,</span> <span class="n">inputs</span><span class="p">,</span> <span class="n">outputs</span> <span class="o">=</span> \
......
Search.setIndex({docnames:["api_en/index_en","api_en/modules","api_en/paddleslim","api_en/paddleslim.analysis","api_en/paddleslim.common","api_en/paddleslim.core","api_en/paddleslim.dist","api_en/paddleslim.models","api_en/paddleslim.nas","api_en/paddleslim.nas.one_shot","api_en/paddleslim.pantheon","api_en/paddleslim.prune","api_en/paddleslim.quant","api_en/search_space_en","index","index_en","install_en","intro_en","model_zoo_en","quick_start/distillation_tutorial_en","quick_start/index_en","quick_start/nas_tutorial_en","quick_start/pruning_tutorial_en","quick_start/quant_aware_tutorial_en","quick_start/quant_post_tutorial_en","tutorials/index_en","tutorials/sensitivity_tutorial_en"],envversion:50,filenames:["api_en/index_en.rst","api_en/modules.rst","api_en/paddleslim.rst","api_en/paddleslim.analysis.rst","api_en/paddleslim.common.rst","api_en/paddleslim.core.rst","api_en/paddleslim.dist.rst","api_en/paddleslim.models.rst","api_en/paddleslim.nas.rst","api_en/paddleslim.nas.one_shot.rst","api_en/paddleslim.pantheon.rst","api_en/paddleslim.prune.rst","api_en/paddleslim.quant.rst","api_en/search_space_en.rst","index.rst","index_en.rst","install_en.md","intro_en.md","model_zoo_en.md","quick_start/distillation_tutorial_en.md","quick_start/index_en.rst","quick_start/nas_tutorial_en.md","quick_start/pruning_tutorial_en.md","quick_start/quant_aware_tutorial_en.md","quick_start/quant_post_tutorial_en.md","tutorials/index_en.rst","tutorials/sensitivity_tutorial_en.md"],objects:{"":{paddleslim:[2,0,0,"-"]},"paddleslim.analysis":{LatencyEvaluator:[3,1,1,""],TableLatencyEvaluator:[3,1,1,""],flops:[3,0,0,"-"],latency:[3,0,0,"-"],model_size:[3,0,0,"-"]},"paddleslim.analysis.LatencyEvaluator":{latency:[3,2,1,""]},"paddleslim.analysis.TableLatencyEvaluator":{latency:[3,2,1,""]},"paddleslim.analysis.flops":{flops:[3,3,1,""]},"paddleslim.analysis.latency":{LatencyEvaluator:[3,1,1,""],TableLatencyEvaluator:[3,1,1,""]},"paddleslim.analysis.latency.LatencyEvaluator":{latency:[3,2,1,""]},"paddleslim.analysis.latency.TableLatencyEvaluator":{latency:[3,2,1,""]},"paddleslim.analysis.model_size":{model_size:[3,3,1,""]},"paddleslim.common":{ControllerClient:[4,1,1,""],ControllerServer:[4,1,1,""],EvolutionaryController:[4,1,1,""],SAController:[4,1,1,""],cached_reader:[4,0,0,"-"],controller:[4,0,0,"-"],controller_client:[4,0,0,"-"],controller_server:[4,0,0,"-"],get_logger:[4,3,1,""],lock:[4,0,0,"-"],log_helper:[4,0,0,"-"],sa_controller:[4,0,0,"-"],unlock:[4,3,1,""]},"paddleslim.common.ControllerClient":{next_tokens:[4,2,1,""],request_current_info:[4,2,1,""],update:[4,2,1,""]},"paddleslim.common.ControllerServer":{close:[4,2,1,""],ip:[4,2,1,""],port:[4,2,1,""],run:[4,2,1,""],start:[4,2,1,""]},"paddleslim.common.EvolutionaryController":{next_tokens:[4,2,1,""],reset:[4,2,1,""],update:[4,2,1,""]},"paddleslim.common.SAController":{best_tokens:[4,4,1,""],current_tokens:[4,4,1,""],max_reward:[4,4,1,""],next_tokens:[4,2,1,""],update:[4,2,1,""]},"paddleslim.common.cached_reader":{cached_reader:[4,3,1,""]},"paddleslim.common.controller":{EvolutionaryController:[4,1,1,""]},"paddleslim.common.controller.EvolutionaryController":{next_tokens:[4,2,1,""],reset:[4,2,1,""],update:[4,2,1,""]},"paddleslim.common.controller_client":{ControllerClient:[4,1,1,""]},"paddleslim.common.controller_client.ControllerClient":{next_tokens:[4,2,1,""],request_current_info:[4,2,1,""],update:[4,2,1,""]},"paddleslim.common.controller_server":{ControllerServer:[4,1,1,""]},"paddleslim.common.controller_server.ControllerServer":{close:[4,2,1,""],ip:[4,2,1,""],port:[4,2,1,""],run:[4,2,1,""],start:[4,2,1,""]},"paddleslim.common.lock":{lock:[4,3,1,""],unlock:[4,3,1,""]},"paddleslim.common.log_helper":{get_logger:[4,3,1,""]},"paddleslim.common.sa_controller":{SAController:[4,1,1,""]},"paddleslim.common.sa_controller.SAController":{best_tokens:[4,4,1,""],current_tokens:[4,4,1,""],max_reward:[4,4,1,""],next_tokens:[4,2,1,""],update:[4,2,1,""]},"paddleslim.core":{GraphWrapper:[5,1,1,""],OpWrapper:[5,1,1,""],Registry:[5,1,1,""],VarWrapper:[5,1,1,""],graph_wrapper:[5,0,0,"-"],registry:[5,0,0,"-"]},"paddleslim.core.GraphWrapper":{"var":[5,2,1,""],all_parameters:[5,2,1,""],clone:[5,2,1,""],get_param_by_op:[5,2,1,""],infer_shape:[5,2,1,""],is_parameter:[5,2,1,""],is_persistable:[5,2,1,""],next_ops:[5,2,1,""],numel_params:[5,2,1,""],ops:[5,2,1,""],pre_ops:[5,2,1,""],program:[5,2,1,""],update_groups_of_conv:[5,2,1,""],update_param_shape:[5,2,1,""],vars:[5,2,1,""]},"paddleslim.core.OpWrapper":{all_inputs:[5,2,1,""],all_outputs:[5,2,1,""],attr:[5,2,1,""],idx:[5,2,1,""],inputs:[5,2,1,""],is_bwd_op:[5,2,1,""],is_opt_op:[5,2,1,""],outputs:[5,2,1,""],set_attr:[5,2,1,""],type:[5,2,1,""]},"paddleslim.core.Registry":{get:[5,2,1,""],module_dict:[5,4,1,""],name:[5,4,1,""],register:[5,2,1,""]},"paddleslim.core.VarWrapper":{inputs:[5,2,1,""],is_parameter:[5,2,1,""],name:[5,2,1,""],outputs:[5,2,1,""],set_shape:[5,2,1,""],shape:[5,2,1,""]},"paddleslim.core.graph_wrapper":{GraphWrapper:[5,1,1,""],OpWrapper:[5,1,1,""],VarWrapper:[5,1,1,""]},"paddleslim.core.graph_wrapper.GraphWrapper":{"var":[5,2,1,""],all_parameters:[5,2,1,""],clone:[5,2,1,""],get_param_by_op:[5,2,1,""],infer_shape:[5,2,1,""],is_parameter:[5,2,1,""],is_persistable:[5,2,1,""],next_ops:[5,2,1,""],numel_params:[5,2,1,""],ops:[5,2,1,""],pre_ops:[5,2,1,""],program:[5,2,1,""],update_groups_of_conv:[5,2,1,""],update_param_shape:[5,2,1,""],vars:[5,2,1,""]},"paddleslim.core.graph_wrapper.OpWrapper":{all_inputs:[5,2,1,""],all_outputs:[5,2,1,""],attr:[5,2,1,""],idx:[5,2,1,""],inputs:[5,2,1,""],is_bwd_op:[5,2,1,""],is_opt_op:[5,2,1,""],outputs:[5,2,1,""],set_attr:[5,2,1,""],type:[5,2,1,""]},"paddleslim.core.graph_wrapper.VarWrapper":{inputs:[5,2,1,""],is_parameter:[5,2,1,""],name:[5,2,1,""],outputs:[5,2,1,""],set_shape:[5,2,1,""],shape:[5,2,1,""]},"paddleslim.core.registry":{Registry:[5,1,1,""]},"paddleslim.core.registry.Registry":{get:[5,2,1,""],module_dict:[5,4,1,""],name:[5,4,1,""],register:[5,2,1,""]},"paddleslim.dist":{single_distiller:[6,0,0,"-"]},"paddleslim.dist.single_distiller":{fsp_loss:[6,3,1,""],l2_loss:[6,3,1,""],loss:[6,3,1,""],merge:[6,3,1,""],soft_label_loss:[6,3,1,""]},"paddleslim.models":{classification_models:[7,0,0,"-"],image_classification:[7,3,1,""],mobilenet:[7,0,0,"-"],mobilenet_v2:[7,0,0,"-"],resnet:[7,0,0,"-"],util:[7,0,0,"-"]},"paddleslim.models.classification_models":{MobileNet:[7,1,1,""],MobileNetV2:[7,1,1,""],ResNet34:[7,3,1,""],ResNet50:[7,3,1,""]},"paddleslim.models.classification_models.MobileNet":{conv_bn_layer:[7,2,1,""],depthwise_separable:[7,2,1,""],net:[7,2,1,""]},"paddleslim.models.classification_models.MobileNetV2":{conv_bn_layer:[7,2,1,""],inverted_residual_unit:[7,2,1,""],invresi_blocks:[7,2,1,""],net:[7,2,1,""],shortcut:[7,2,1,""]},"paddleslim.models.mobilenet":{MobileNet:[7,1,1,""]},"paddleslim.models.mobilenet.MobileNet":{conv_bn_layer:[7,2,1,""],depthwise_separable:[7,2,1,""],net:[7,2,1,""]},"paddleslim.models.mobilenet_v2":{MobileNetV2:[7,1,1,""],MobileNetV2_scale:[7,3,1,""],MobileNetV2_x1_0:[7,3,1,""],MobileNetV2_x1_5:[7,3,1,""],MobileNetV2_x2_0:[7,3,1,""]},"paddleslim.models.mobilenet_v2.MobileNetV2":{conv_bn_layer:[7,2,1,""],inverted_residual_unit:[7,2,1,""],invresi_blocks:[7,2,1,""],net:[7,2,1,""],shortcut:[7,2,1,""]},"paddleslim.models.resnet":{ResNet101:[7,3,1,""],ResNet152:[7,3,1,""],ResNet34:[7,3,1,""],ResNet50:[7,3,1,""],ResNet:[7,1,1,""]},"paddleslim.models.resnet.ResNet":{basic_block:[7,2,1,""],bottleneck_block:[7,2,1,""],conv_bn_layer:[7,2,1,""],net:[7,2,1,""],shortcut:[7,2,1,""]},"paddleslim.models.util":{image_classification:[7,3,1,""]},"paddleslim.nas":{one_shot:[9,0,0,"-"],sa_nas:[8,0,0,"-"]},"paddleslim.nas.one_shot":{OneShotSearch:[9,3,1,""],OneShotSuperNet:[9,1,1,""],SuperMnasnet:[9,1,1,""],one_shot_nas:[9,0,0,"-"],super_mnasnet:[9,0,0,"-"]},"paddleslim.nas.one_shot.OneShotSuperNet":{forward:[9,2,1,""],init_tokens:[9,2,1,""],range_table:[9,2,1,""]},"paddleslim.nas.one_shot.SuperMnasnet":{get_flops:[9,2,1,""],init_tokens:[9,2,1,""],range_table:[9,2,1,""]},"paddleslim.nas.one_shot.one_shot_nas":{OneShotSearch:[9,3,1,""],OneShotSuperNet:[9,1,1,""]},"paddleslim.nas.one_shot.one_shot_nas.OneShotSuperNet":{forward:[9,2,1,""],init_tokens:[9,2,1,""],range_table:[9,2,1,""]},"paddleslim.nas.one_shot.super_mnasnet":{SuperMnasnet:[9,1,1,""]},"paddleslim.nas.one_shot.super_mnasnet.SuperMnasnet":{get_flops:[9,2,1,""],init_tokens:[9,2,1,""],range_table:[9,2,1,""]},"paddleslim.nas.sa_nas":{SANAS:[8,1,1,""]},"paddleslim.nas.sa_nas.SANAS":{current_info:[8,2,1,""],next_archs:[8,2,1,""],reward:[8,2,1,""],tokens2arch:[8,2,1,""]},"paddleslim.pantheon":{Student:[10,1,1,""],Teacher:[10,1,1,""],student:[10,0,0,"-"],teacher:[10,0,0,"-"],utils:[10,0,0,"-"]},"paddleslim.pantheon.Student":{get_knowledge_desc:[10,2,1,""],get_knowledge_generator:[10,2,1,""],get_knowledge_qsize:[10,2,1,""],recv:[10,2,1,""],register_teacher:[10,2,1,""],send:[10,2,1,""],start:[10,2,1,""]},"paddleslim.pantheon.Teacher":{dump:[10,2,1,""],recv:[10,2,1,""],send:[10,2,1,""],start:[10,2,1,""],start_knowledge_service:[10,2,1,""]},"paddleslim.pantheon.student":{Student:[10,1,1,""]},"paddleslim.pantheon.student.Student":{get_knowledge_desc:[10,2,1,""],get_knowledge_generator:[10,2,1,""],get_knowledge_qsize:[10,2,1,""],recv:[10,2,1,""],register_teacher:[10,2,1,""],send:[10,2,1,""],start:[10,2,1,""]},"paddleslim.pantheon.teacher":{Teacher:[10,1,1,""]},"paddleslim.pantheon.teacher.Teacher":{dump:[10,2,1,""],recv:[10,2,1,""],send:[10,2,1,""],start:[10,2,1,""],start_knowledge_service:[10,2,1,""]},"paddleslim.pantheon.utils":{EndSignal:[10,1,1,""],StartSignal:[10,1,1,""],SyncSignal:[10,1,1,""],check_ip:[10,3,1,""],convert_dtype:[10,3,1,""]},"paddleslim.prune":{AutoPruner:[11,1,1,""],Pruner:[11,1,1,""],SensitivePruner:[11,1,1,""],auto_pruner:[11,0,0,"-"],conv2d:[11,1,1,""],flops_sensitivity:[11,3,1,""],get_ratios_by_loss:[11,3,1,""],load_model:[11,3,1,""],load_sensitivities:[11,3,1,""],merge_sensitive:[11,3,1,""],prune_io:[11,0,0,"-"],prune_walker:[11,0,0,"-"],pruner:[11,0,0,"-"],save_model:[11,3,1,""],sensitive:[11,0,0,"-"],sensitive_pruner:[11,0,0,"-"],sensitivity:[11,3,1,""]},"paddleslim.prune.AutoPruner":{prune:[11,2,1,""],reward:[11,2,1,""]},"paddleslim.prune.Pruner":{prune:[11,2,1,""]},"paddleslim.prune.SensitivePruner":{get_ratios_by_sensitive:[11,2,1,""],greedy_prune:[11,2,1,""],prune:[11,2,1,""],restore:[11,2,1,""],save_checkpoint:[11,2,1,""]},"paddleslim.prune.auto_pruner":{AutoPruner:[11,1,1,""]},"paddleslim.prune.auto_pruner.AutoPruner":{prune:[11,2,1,""],reward:[11,2,1,""]},"paddleslim.prune.prune_io":{load_model:[11,3,1,""],save_model:[11,3,1,""]},"paddleslim.prune.prune_walker":{conv2d:[11,1,1,""]},"paddleslim.prune.pruner":{Pruner:[11,1,1,""]},"paddleslim.prune.pruner.Pruner":{prune:[11,2,1,""]},"paddleslim.prune.sensitive":{flops_sensitivity:[11,3,1,""],get_ratios_by_loss:[11,3,1,""],load_sensitivities:[11,3,1,""],merge_sensitive:[11,3,1,""],sensitivity:[11,3,1,""]},"paddleslim.prune.sensitive_pruner":{SensitivePruner:[11,1,1,""]},"paddleslim.prune.sensitive_pruner.SensitivePruner":{get_ratios_by_sensitive:[11,2,1,""],greedy_prune:[11,2,1,""],prune:[11,2,1,""],restore:[11,2,1,""],save_checkpoint:[11,2,1,""]},"paddleslim.quant":{quant_embedding:[12,0,0,"-"],quanter:[12,0,0,"-"]},"paddleslim.quant.quant_embedding":{quant_embedding:[12,3,1,""]},"paddleslim.quant.quanter":{convert:[12,3,1,""],quant_aware:[12,3,1,""],quant_post:[12,3,1,""]},paddleslim:{analysis:[3,0,0,"-"],common:[4,0,0,"-"],core:[5,0,0,"-"],dist:[6,0,0,"-"],models:[7,0,0,"-"],pantheon:[10,0,0,"-"],prune:[11,0,0,"-"],quant:[12,0,0,"-"],version:[2,0,0,"-"]}},objnames:{"0":["py","module","Python module"],"1":["py","class","Python class"],"2":["py","method","Python method"],"3":["py","function","Python function"],"4":["py","attribute","Python attribute"]},objtypes:{"0":"py:module","1":"py:class","2":"py:method","3":"py:function","4":"py:attribute"},terms:{"6\u7248\u672c\u6216\u66f4\u65b0\u7248\u672c":16,"7\u7248\u672c":26,"\u4e0b\u8f7d":18,"\u4e0b\u8f7d\u94fe\u63a5":18,"\u4e2d\u6587\u6587\u6863":15,"\u4ee5\u4e0b\u7ae0\u8282\u4f9d\u6b21\u6b21\u4ecb\u7ecd\u6bcf\u4e2a\u6b65\u9aa4\u7684\u5185\u5bb9":26,"\u5206\u6790\u654f\u611f\u5ea6":26,"\u526a\u88c1\u6a21\u578b":26,"\u538b\u7f29\u65b9\u6cd5":18,"\u5b89\u88c5\u5386\u53f2\u7248\u672c":16,"\u5b89\u88c5\u5b98\u65b9\u53d1\u5e03\u7684\u6700\u65b0\u7248\u672c":16,"\u5b89\u88c5develop\u7248\u672c":16,"\u5b89\u88c5paddleslim\u524d":16,"\u5b9a\u4e49\u6a21\u578b\u8bc4\u4f30\u65b9\u6cd5":26,"\u5b9a\u4e49\u8f93\u5165\u6570\u636e":26,"\u5e26_vd\u540e\u7f00\u4ee3\u8868\u8be5\u9884\u8bad\u7ec3\u6a21\u578b\u4f7f\u7528\u4e86mixup":18,"\u6570\u636e\u96c6":18,"\u6784\u5efa\u6a21\u578b":26,"\u67e5\u770b\u53ef\u5b89\u88c5\u5386\u53f2\u7248\u672c":16,"\u6a21\u578b":18,"\u6a21\u578b\u4f53\u79ef":18,"\u7136\u540e\u6309\u4ee5\u4e0b\u65b9\u5f0f\u5bfc\u5165paddle\u548cpaddleslim":26,"\u83b7\u53d6\u5f85\u5206\u6790\u5377\u79ef\u53c2\u6570\u540d\u79f0":26,"\u8bad\u7ec3\u6a21\u578b":26,"\u8be5\u6559\u7a0b\u4ee5\u56fe\u50cf\u5206\u7c7b\u6a21\u578bmobilenetv1\u4e3a\u4f8b":26,"\u8be5\u793a\u4f8b\u5305\u542b\u4ee5\u4e0b\u6b65\u9aa4":26,"\u8bf4\u660e\u5982\u4f55\u5feb\u901f\u4f7f\u7528":26,"\u8bf7\u70b9\u51fb":16,"\u8bf7\u786e\u8ba4\u5df2\u6b63\u786e\u5b89\u88c5paddl":26,"\u8bf7\u786e\u8ba4\u5df2\u6b63\u786e\u5b89\u88c5paddle1":16,"\u8f93\u5165320":18,"\u8f93\u5165416":18,"\u8f93\u5165608":18,"\u8f93\u5165\u5c3a\u5bf8":18,"abstract":[3,4],"class":[3,4,5,7,8,9,10,11,13],"default":[3,4,6,8,9,10,11,12,19,23],"final":[9,12,21,23,24],"float":[3,4,5,6,8,11,21,23],"function":[4,5,6,8,9,11,12,13,19,22,23,24],"imagenet1000\u7c7b":18,"import":[4,13,26],"int":[3,4,5,8,9,10,11,12],"mixup\u76f8\u5173\u4ecb\u7ecd\u53c2\u8003":18,"new":[4,5,13],"paddle\u5b89\u88c5\u6559\u7a0b":16,"paddle\u5b89\u88c5\u8bf7\u53c2\u8003":16,"paddleslim\u4f9d\u8d56paddle1":26,"paddleslim\u7684\u654f\u611f\u5ea6\u5206\u6790\u63a5\u53e3":26,"public":10,"return":[3,4,5,6,8,9,10,11,12,13,21],"static":10,"super":9,"true":[3,7,8,10,11,12,19,21,22,23,24],"try":[4,11],"var":[5,6,19,23,24],"while":[8,9,11],And:[11,22],For:[4,8,13],NAS:[17,18],NOT:13,One:17,Ops:19,The:[3,4,5,6,8,9,10,11,12,19,21,22,23,24],Then:[23,24],There:24,Use:13,__dict__:19,__init__:13,__name__:4,_bn:13,_conv0:13,_conv1:13,_conv2:13,_conv:13,_conv_bn_lay:13,_elementwise_add:13,_resnet_block:13,_shortcut:13,aadvanc:15,about:[8,13],abs:[13,18],abs_max:12,acc1:[19,21,22,23,24],acc5:[19,21,22,23,24],acc:18,acc_top1:[19,21],acc_top5:[19,21],accept:[9,11],accord:[4,5,8,11,13,21,23],accuraci:[11,19,21,23,24],accuracy_loss:11,act:[7,13],activ:[12,24],activation_bit:12,adam:21,add:[3,6,12,13,23],added:[6,10],address:[4,8,10],after:[4,5,21,24],again:11,agent:4,algo:12,algorithm:8,all:[3,4,5,6,8,10,11,12,19],all_input:5,all_output:5,all_paramet:5,alreadi:10,also:[11,17,19],analysi:[0,1,2,21,22],analysis:11,ani:[5,10],anneal:[4,8,11,17],api:[12,15,19,21,22,23,24],append:[11,13,19,21,23,24],appli:12,applic:17,arch:21,architectur:[4,8,13,17,19,20],arg:8,argument:[9,10,11],arrai:[13,21,23,24],arxiv:[13,18],asctim:4,assign:10,attr:5,attribut:5,auto:18,auto_prun:[1,2],autom:17,automat:[4,17],autoprun:11,avg_cost:[19,21],avoid:19,awar:[17,20],axi:[13,21],backup:11,backward:5,base:[3,4,5,8,9,10,11,13,17,21,22],baselin:18,basic_block:7,basicconfig:4,batch:[10,12,17,19,21,22,23,24],batch_gener:10,batch_norm:13,batch_num:[12,24],batch_reward:21,batch_siz:[10,12,19,21,22,23,24],becaus:[23,24],befor:[4,6,12],below:[11,19,22],best:[4,8,9,11],best_token:4,better:8,between:[11,12],beyond:18,bigger:8,bind:4,bit:12,blazefac:18,blob:13,block:[8,13],block_mask:[8,13],block_num:[8,13],bn5c:19,bool:[3,5,8,10,11,12],bottleneck_block:7,bottleneck_params_list:13,box:18,bracket:12,branch2b:19,buf_siz:[10,21],buffer:10,build_program:21,cach:4,cache_dir:12,cache_path:4,cached_id:4,cached_read:[1,2],calcul:[3,11,12,24],calibr:[12,24],call:[9,10,23,24],callback:[4,9,11],can:[5,8,10,11,12,13,19,23],cann:11,cannot:23,capac:10,carri:10,categori:19,caus:19,certain:8,certainli:8,ch_out:7,chang:[22,23],change_depth:7,channel:[7,9,11,13,17,20],channel_in:13,channel_num:13,chapter:21,check:4,check_ip:10,checkpoint:[4,8,11],cifar10:21,cifar:21,cityscap:18,class_dim:[7,19],class_num:7,classif:[20,25],classification_model:[1,2],classsif:22,client:[4,11],client_nam:4,client_num:4,clip:12,clone:[5,16,21],close:[4,23,24],cls:5,coco:18,code:[13,19,22],collect:13,com:[13,16],combin:6,command:10,common:[1,2,10],commun:11,compiledprogram:12,compress:17,comput:[9,11],condit:11,config:[4,8,10,12,13,21],configur:[8,23],conflict:19,connect:[4,11],consid:11,consist:[6,8],constrain:17,constrain_func:4,constraint:[4,21],construct:[13,23,24],contain:[9,10,21,23,24],continu:21,control:[1,2,8,11],control_token:4,controller_cli:[1,2],controller_serv:[1,2],controllercli:4,controllerserv:4,conv1:7,conv1_nam:7,conv2_1_sep_weight:22,conv2_2_sep_weight:22,conv2d:[11,12,13,19],conv:13,conv_bn_lay:[7,13],conveni:[23,24],converg:8,convert:[8,12,23],convert_dtyp:10,convlut:3,convolut:[3,5,11,13],core:[1,2],correctli:[19,21,22,23,24],correspind:8,correspond:[8,10,19],cost:[19,21],count:[3,4],cpu:10,cpu_num:10,cpuplac:[6,11,12,19,21,22,23,24],criterion:11,cross_entropi:[19,21],cuda_visible_devic:10,cudaplac:[6,11,12],current:[3,4,5,8,9,11,13,17,21],current_flop:21,current_info:8,current_token:4,cut:11,cycl:21,data:[4,8,10,12,17,19,22],data_feed:21,data_map_map:6,data_name_map:[6,19],data_read:21,data_residu:7,datafeed:[19,21,22,23,24],dataload:[10,12],dataset:[4,11,19,21,23,24],dcn:18,decai:[4,11],decor:13,deep:17,deeplabv3:18,def:[13,21,23,24],defalut:[11,12],default_main_program:21,defin:[3,4,5,6,9,10,13,23,24],delimit:3,demo:[19,22],denot:10,depend:[23,24],depthwis:19,depthwise_conv2d:12,depthwise_conv2d_11:19,depthwise_separ:7,dequant:[12,23],describ:21,descript:10,design:17,detail:[3,8],determin:10,develop:[13,17],devic:[3,6,10,11,12],dict:[3,4,5,6,8,10,11,12],dictionari:[8,10],differ:[10,13,17],differenct:11,dimens:6,direct:12,directli:21,directori:[8,11],dirnam:[11,23,24],disabl:4,discret:8,disk:12,dist:[0,1,2,19],distil:[6,17,18],distribut:17,divergenc:12,divid:6,document:15,doe:[23,24],doesn:10,doing:24,donnot:4,down:11,download:[19,21,22,23,24],drop:10,drop_last:[10,19,22,23,24],dtype:[10,12,19,21,23],dump:10,dure:8,dygraph:9,dynam:[9,10,17],each:[3,9,10,11,21],easi:18,easili:22,element:[5,11],elementwise_add:13,els:[4,13],empir:18,emsp:13,end:10,endsign:10,engin:3,ensur:[19,22],enumer:13,environ:10,epoch:[19,21,22,23,24],equal:11,estim:17,eval_feed:21,eval_func:[9,11],eval_progarm:21,eval_program:[11,21],eval_read:[4,21],evalu:[3,4,11],everi:[9,12,13],evolutionari:4,evolutionarycontrol:4,exampl:[4,13,23,24],except:6,excut:[19,22],exe:[10,11,19,21,22,23,24],execut:[9,10,11],executor:[10,11,12,19,21,23,24],exist:13,expansion_factor:7,experi:[8,21],explor:8,extrem:8,face:18,factor:12,failur:8,fake:12,fals:[3,5,7,8,9,10,11,12,21,22,23],fast:18,faster:8,fc_name:7,feed:[10,19,21,22,23,24],feed_list:10,feed_target_nam:24,feeded_var_nam:[23,24],fetch:10,fetch_list:[19,21,22,23,24],fetch_target:24,file:[3,4,5,10,11,12,13],filenam:12,filesystem:11,filter:[5,11],filter_num:13,filter_s:[7,13],finally_reward:21,finetun:23,finish:10,first:[8,23,24],fit:19,flags_selected_gpu:10,float32:[19,21,23],float_prog:23,flop:[1,2,11,13,17,21],flops_sensit:11,fluid:[3,5,6,9,10,11,12,13,19,21,22,23,24,26],fmt:4,follow:[10,13,19,21,22,23,24],for_test:[5,12,21,23],form:19,formal:[23,24],format:[3,4,8,9,10,11,13,19,21,22,23],forward:[9,24],fp32:12,framework:[5,17,23,24],freez:12,freezed_program:12,freezed_program_int8:12,from:[4,5,6,10,11,13,17,19,21,23],fsp:6,fsp_loss:6,func:10,further:17,futur:17,gener:[4,8,9,10,11,12,24],get:[3,4,5,8,9,10,11,12,13,19,21,23,24],get_flop:9,get_knowledge_desc:10,get_knowledge_gener:10,get_knowledge_qs:10,get_logg:4,get_param_by_op:5,get_ratios_by_loss:11,get_ratios_by_sensit:11,gflop:18,git:16,github:[13,16],given:[3,4,5,11],global:[6,17,22],global_block:[23,24],global_scop:[12,22],gpu:[10,18],graph:[3,5,9,10,11],graph_wrapp:[1,2],graphwrapp:5,grapwrapp:3,greater:8,greedi:8,greedy_prun:11,group:[5,7,11],guard:19,handl:4,hard:18,hardwar:17,has:[8,13],have:[19,21,22,23,24],head:13,higher:[8,13],host:[8,11],how:[8,19,21,22,23,24],http:[13,16,18],human:5,hyperparamet:[4,17],ident:11,identifi:4,ids:10,idx:5,if_act:7,ifshortcut:7,ignor:10,imag:[18,20,25],image_classif:[7,13,22,23,24],image_shap:7,in_address:10,in_c:7,in_nod:5,in_path:10,inception_v4:13,inceptionablock:13,inceptionablockspac:13,inceptioncblock:13,inceptioncblockspac:13,includ:[5,8,10,21],index:13,indic:[5,6,9],industri:17,infer:[3,10,12,23,24],infer_shap:5,inference_model:[23,24],inferfac:[23,24],info:4,inform:[4,8,11],inherit:13,init:[4,9,11],init_ratio:11,init_temperatur:[4,8,11],init_token:[4,8,9,13],initi:[4,8,13],input:[5,6,7,8,9,10,12,13,19,22],input_channel:9,input_data:21,input_s:[8,13],insert:12,instal:[15,19,21,22,23,24],instanc:[5,8,9,11],int64:[19,21],int8:[12,23],int8_prog:23,integ:9,interfac:6,introduct:15,inverted_residual_unit:7,invresi_block:7,irgraph:5,is_bwd_op:5,is_first:7,is_full_quant:12,is_opt_op:5,is_paramet:5,is_persist:5,is_serv:[8,11],is_use_cache_fil:12,iter:[4,11,23,24],iterm:13,its:10,jump:21,just:[3,22],kei:[3,4,5,6,8,10,11,12,19],kernel:13,knowledg:[10,17],kwarg:6,l140:13,l148:13,l173:13,l174:13,l1_norm:11,l291:13,l29:13,l2_loss:[6,19],l30:13,label:[6,19,21],languag:12,larg:8,last:[4,10],latenc:[1,2,11,13,17],latencyevalu:3,latest:[4,11],launch:10,layer:[3,5,7,9,13,19,21],layer_set:13,lazi:11,learn:[19,22,23],learning_r:21,least:9,legal:[4,11],len:13,length:[8,11,13],less:[8,10,11],level:[4,10,17],levelnam:4,librari:[11,17],light:[4,17],lightweight:17,limit:10,line:19,lis:9,list:[4,5,8,9,10,11,12,13,19],list_var:19,listen:4,lite:[18,23],load:[5,8,11,12,23,24],load_checkpoint:8,load_inference_model:24,load_model:11,load_sensit:11,local:4,lock:[1,2],lod:10,log:4,log_help:[1,2],logger:4,lookup_t:12,loss:[6,11,21,22,23,24],loss_func:6,loss_np:19,lower:8,main:19,main_program:[23,24],make:[21,22,23,24],map:[6,12],max:[4,11],max_client_num:[4,11],max_ratio:11,max_reward:4,max_try_tim:[4,11],max_valu:9,maximum:[4,9,10],mean:[4,8,9,10,11,13,19,21,23,24],medium:18,meet:4,memori:12,merg:[6,10,11],merge_sensit:11,merge_strategi:10,messag:4,method:[3,4,10,12,19,23,24],min:11,min_ratio:11,min_valu:9,mini:24,minim:[18,19,21],minimum:9,miou:18,mixup:18,mnist:[19,22,23,24],mobilenet:[1,2,18,19,22,23,24],mobilenet_v1:13,mobilenet_v2:[1,2,13],mobilenetv1:[18,19,22,23,24],mobilenetv1block:13,mobilenetv1blockspac:13,mobilenetv1spac:13,mobilenetv2:[7,13,18,21],mobilenetv2_scal:7,mobilenetv2_x1_0:7,mobilenetv2_x1_5:7,mobilenetv2_x2_0:7,mobilenetv2block:13,mobilenetv2blockspac:13,mobilenetv2spac:[13,21],mobilnetv1:13,mode:[3,9,10],model:[1,2,3,6,8,9,10,11,12,13,15,17,20,25],model_dir:[12,24],model_filenam:12,model_s:[1,2],modifi:11,modul:1,module_dict:5,momentum:19,monitor:10,more:[8,12,17,19],much:8,mul:[3,12],multi:17,multipl:10,must:[11,12],name:[3,4,5,6,7,8,9,10,11,12,13,18,19,21,22,23,24],name_prefix:6,name_scop:9,namespac:13,nas:[0,1,2,4,21],nas_checkpoint:8,necessari:[10,13,21],need:[8,13,19,21,23,24],nerual:20,net:[7,9,19],net_arch:13,network:[8,9,11,17,19],neural:[4,8,13,21],never:4,next:[4,5,8,21],next_arch:[8,21],next_op:5,next_token:4,nlp:17,node:[5,10],none:[4,5,6,7,8,9,10,11,12,13,19,21],normal:8,note:[8,18,22,23,24],now:10,num_filt:[7,13],num_filters1:7,num_filters2:7,num_group:7,num_in_filt:7,number:[3,4,5,8,10,11,12,13,19,22],numeb:13,numel_param:5,numpi:[13,21,23,24],obj365_pretrain:18,object:[3,4,5,8,10,11],observ:19,obtain:[8,12],offlin:10,onc:10,one:[9,10,19,23,24],one_shot:[0,2,8],one_shot_na:[2,8],oneshotsearch:9,oneshotsupernet:9,onli:[3,8,10,11,12,13,23,24],onlin:10,only_conv:3,only_graph:11,open:17,oper:[3,5,12,19,23],ops:5,opt:19,optim:[5,19,21],option:12,opwrapp:5,order:[10,19,21,23,24],org:[13,16,18],origin:13,other:[6,10],otherwis:[3,9,12],out:[10,19],out_channel:9,out_nod:5,out_path:10,out_port:10,output:[4,5,8,9,10,19,21,22,23,24],output_s:[8,13],overwrit:13,packag:[0,1,19,22],pad:[7,13],paddl:[4,5,6,9,11,19,21,22,23,24,26],paddle1:[19,22,23,24],paddlecv:13,paddlepaddl:[13,16,17],paddleslim:[0,16,17,19,21,22,23,24,26],pair:10,pantheon:[0,1,2],paper:13,param:[4,8,11,12,22],param_backup:11,param_nam:11,param_shape_backup:11,paramat:11,paramet:[3,4,5,6,8,9,10,11,12,22,23,24],params_filenam:12,params_nam:12,pars:10,partial:4,pasacl:18,pascal:18,path:[3,4,10,12],pdf:13,percent:11,percis:13,perform:[3,9,19,23,24],persist:5,pickl:11,pip:16,place:[6,11,12,21,22,23],platform:17,pleas:[8,19,21,22,23,24],plu:10,pop:10,popular:17,port:[4,8,10,11],posit:9,possibl:8,post:[12,20],practic:17,pre:[21,23,24],pre_op:5,precis:12,predict:[10,19],prefix:[6,19],prefix_nam:7,preform:[23,24],preserv:8,previou:5,print:[19,21,22,23,24],probabl:8,process:[13,17,23,24],prog:[23,24],program:[3,5,6,10,11,12,23,24],program_guard:[19,21],provid:12,prune:[0,1,2,5,17,20,25],prune_io:[1,2],prune_walk:[1,2],pruned_flop:11,pruned_flops_r:11,pruned_lat:11,pruned_param:11,pruned_program:[11,22],pruned_ratio:11,pruner:[1,2,22],prunework:11,purpos:13,push:10,pypi:16,pyread:10,python:[10,12,13,16],qsize:10,quant:[0,1,2,23,24],quant_awar:[12,18,23],quant_embed:[1,2],quant_post:[12,18,24],quant_post_model:24,quant_post_prog:24,quant_program:23,quanter:[1,2],quantiz:[12,17,20],quantizable_op_typ:12,quantize_bit:12,quantize_model_path:[12,24],quantize_typ:12,queue:10,quick:15,r50:18,random:[4,8],randomli:8,rang:[4,8,9,13,21,23],range_t:[4,9,13],rate:[4,8,11,23],ratio:[11,22],reach:[10,23,24],read:[19,21,22,23,24],readabl:5,reader:[4,10,19,21,22,23,24],reader_config:10,real:10,reason:[23,24],receiv:10,reciev:10,record:[3,12],recv:10,reduc:8,reduce_r:[4,8,11],reduct:8,refer:[8,13],regist:[5,10,13],register_teach:10,registr:10,registri:[1,2],relu:[7,13],rememb:4,repeat:[10,13],repeat_tim:9,repres:[6,9,12,13],request:4,request_current_info:4,res:[23,24],reset:4,resnet101:[7,18],resnet152:7,resnet34:[7,18],resnet50:[7,18,19],resnet50_vd1:18,resnet50_vd:18,resnet:[1,2,13],resnet_lay:13,resnetblock:13,resnetblockspac:13,resnetblockspace2:13,resnetspac:13,respect:10,restor:11,result:[23,24],reward:[4,8,11,21],reward_avg:21,risk:18,rtype:8,run:[4,6,10,12,19,21,22,23,24],sa_control:[1,2],sa_na:[1,2],sacontrol:4,same:[4,10,12,13,17,19],sampl:[4,10,12,17,24],sample_gener:[10,12,24],sample_list_gener:10,sampled_r:4,sana:[4,8,13],satisfi:21,save:[4,8,11,12,24],save_checkpoint:[8,11,21],save_inference_model:[12,23,24],save_int8:[12,23],save_model:11,scalar:11,scale:[7,12,24],scene:4,schema:10,scnn:18,scope:[5,6,9,11,12,22],score:[8,11],search:[0,4,8,9,11,17,20],search_space_bas:13,search_space_registri:13,search_step:[4,8,9,11],searcher:4,searchspac:13,searchspacebas:13,second:6,section:[21,22,23,24],see:[10,19],select:[23,24],self:[6,13],send:10,sensit:[1,2,17,18,25],sensitive_prun:[1,2],sensitiveprun:11,sensitivities_fil:11,sent:10,separ:12,serv:10,server:[4,8,11],server_addr:[8,11,21],server_ip:4,server_port:4,servic:10,set:[4,5,8,9,10,11,12,13],set_attr:5,set_shap:5,sett:4,setup:16,shape:[5,10,11,13,19,21,22],share:10,shortcut:7,shortcut_conv:13,shot:[9,17],should:[4,6,9,10,11,12,23],show:[21,23,24],shuffl:21,similar:12,simpl:[16,22],simplifi:[23,24],simul:[4,8,11,17],simultan:4,singl:[11,12,17],single_distil:[1,2],size:[3,8,10,12,13,21,23,24],slim:[4,5,19,21,22,23,24,26],slower:8,small:[8,17,23,24],smaller:[8,13,23],socket:4,soft:6,soft_label_loss:6,softmax:[6,21],softmax_out:21,solut:4,some:[3,5,11],some_batch_genr:10,some_sample_gener:10,some_sample_list_gener:10,sort:11,sourc:[4,17],space:[0,4,8,9],special:5,specifi:[6,10,13,19],speed:[23,24],stabl:8,stage:9,start:[4,8,10,15],start_ev:21,start_knowledge_servic:10,start_train:21,startsign:10,startup_program:21,state:8,statu:4,steadi:8,step3:21,step:[4,8,9,11,21],stop:4,store:[11,22],str:[3,4,5,6,8,9,10,11,12],strategi:[9,10,11],stride:[7,9,13],string:[2,8],strong:8,strore:11,structur:[17,23,24],student:[1,2,6,18,19],student_feature_map:6,student_model_var:19,student_program:6,student_startup:19,student_temperatur:6,student_var1:6,student_var1_nam:6,student_var2:6,student_var2_nam:6,student_var:[6,19],student_var_nam:6,sub:[8,9],submodul:[1,17],subpackag:1,successfulli:8,suggest:8,suitabl:23,sum:10,super_mnasnet:[2,8],supermnasnet:9,support:[10,11,12,17],sure:21,sychron:10,synchron:10,syncsign:10,system:4,tabl:[4,9],table_fil:3,tablelatencyevalu:3,target:[3,5,11],target_var:[23,24],task:[4,8,22],teacher:[1,2,6,18,19],teacher_:6,teacher_bn5c_branch2b:19,teacher_feature_map:6,teacher_id:10,teacher_model:19,teacher_model_var:19,teacher_program:6,teacher_startup:19,teacher_temperatur:6,teacher_var1:6,teacher_var1_nam:6,teacher_var2:6,teacher_var2_nam:6,teacher_var:[6,19],teacher_var_nam:6,techniqu:17,temp:12,temp_post_train:12,temperatur:[4,6,8,11],tensor:[5,12],test10:21,test:[11,12,19,21,22],test_program:21,test_read:[23,24],than:[8,10,11],thei:[23,24],them:[4,10],thi:[5,6,8,10,11,12,19,21,22,23,24],thread:10,three:10,threshold:[11,12],time:[4,10,12,19],tmp:19,tmp_0:19,tmp_3:19,token2arch:13,token:[4,8,9,11,13],tokens2arch:8,top1:[23,24],top5:[23,24],top:18,topk:11,total:[3,4,9],train10:21,train:[9,11,12,17,20],train_feed:[19,21,22,23,24],train_program:[11,21,22,23,24],train_read:[19,21,22,23,24],trans1:18,transfer:[10,17],transform:13,trial:10,tupl:[3,8,9,11,12],tutori:[15,19,21,22,23,24],two:19,type:[3,4,5,6,8,9,10,11,12],uncom:19,under:12,unifi:19,uniform:[6,11,17,18],uniqu:10,unique_nam:19,unlock:4,unrel:10,unstabl:8,until:10,updat:[4,5,8,11],update_groups_of_conv:5,update_param_shap:5,usabl:4,use:[4,5,8,12,19,21,22,23,24],use_auxhead:9,use_cudnn:[7,21],use_gpu:[7,22,23,24],used:[3,4,5,6,8,9,10,11,12,13,21,22,23],useful:17,user:[5,6,12],uses:[12,21],using:[4,12,23,24],usual:12,util:[1,2,12],val_program:[22,23,24],val_quant_program:23,valid:5,valu:[3,5,6,8,9,10,11,19,22],varaibl:9,variabl:[5,6,9,10,11,12,19],varibal:5,varwrapp:5,verifi:19,version:1,visit:11,voc:18,wait:10,want:[8,13,21],weight:[11,12,17],weight_0:11,weight_1:11,weight_bit:12,well:[12,23,24],what:21,when:[10,11,12,23,24],whenev:10,where:[6,11,19],whether:[3,4,5,8,10,11,12],which:[4,6,8,9,11,12,19,21,23,24],whose:[3,9,10,11],why:8,wider:18,wise:17,without:[4,23,24],workflow:[19,22],wors:8,would:11,wrapper:[4,5,10],writer:10,wrote:10,yet:10,yolov3:18,you:[8,13,19,21,22,23,24],yourself:8,zero:11,zoo:15},titles:["API Documents","paddleslim","paddleslim package","paddleslim.analysis package","paddleslim.common package","paddleslim.core package","paddleslim.dist package","paddleslim.models package","paddleslim.nas package","paddleslim.nas.one_shot package","paddleslim.pantheon package","paddleslim.prune package","paddleslim.quant package","search space","\u4e2d\u6587\u6587\u6863","Welcome to use PaddleSlim.","Install","Introduction","Model Zoo","Knowledge Distillation for Image Classification","Quick Start","Nerual Architecture Search for Image Classification","Channel Pruning for Image Classification","Training-aware Quantization of image classification model - quick start","Post-training Quantization of image classification model - quick start","Aadvanced Tutorials","Pruning of image classification model - sensitivity"],titleterms:{"\u4e2d\u6587\u6587\u6863":14,"\u526a\u88c1":18,"\u56fe\u50cf\u5206\u5272":18,"\u56fe\u8c61\u5206\u7c7b":18,"\u5bfc\u5165\u4f9d\u8d56":26,"\u76ee\u6807\u68c0\u6d4b":18,"\u84b8\u998f":18,"\u91cf\u5316":18,"function":21,"import":[19,21,22,23,24],aadvanc:25,about:21,add:19,after:[22,23],analysi:3,api:0,architectur:[21,23,24],auto_prun:11,awar:23,bofor:22,build:[21,22],cached_read:4,channel:22,classif:[19,21,22,23,24,26],classification_model:7,common:4,comput:22,control:4,controller_cli:4,controller_serv:4,core:5,data:[21,23,24],dataset:22,defin:[19,21,22],definit:[23,24],depend:[19,21,22],dist:6,distil:19,document:0,evalu:21,exampl:21,featur:19,fetch:21,flop:[3,22],full:21,funciton:21,graph_wrapp:5,how:13,imag:[19,21,22,23,24,26],initi:21,input:[21,23,24],instal:16,instanc:21,introduct:17,knowledg:19,latenc:3,lock:4,log_help:4,loss:19,map:19,merg:19,method:17,mobilenet:7,mobilenet_v2:7,model:[7,18,19,21,22,23,24,26],model_s:3,modul:[2,3,4,5,6,7,8,9,10,11,12],nas:[8,9,13],necessari:[23,24],nerual:21,normal:[23,24],one_shot:9,one_shot_na:9,packag:[2,3,4,5,6,7,8,9,10,11,12],paddleslim:[1,2,3,4,5,6,7,8,9,10,11,12,13,15],pantheon:10,post:24,program:[19,21],provid:13,prune:[11,22,26],prune_io:11,prune_walk:11,pruner:11,quant:12,quant_embed:12,quanter:12,quantiz:[23,24],quick:[20,23,24],registri:5,resnet:7,retur:21,sa_control:4,sa_na:8,sana:21,save:23,score:21,search:[13,21],select:19,sensit:[11,26],sensitive_prun:11,single_distil:6,space:13,start:[20,21,23,24],student:10,student_program:19,submodul:[2,3,4,5,6,7,8,9,10,11,12],subpackag:[2,8],super_mnasnet:9,teacher:10,teacher_program:19,test:[23,24],train:[19,21,22,23,24],tutori:25,use:[13,15],util:[7,10],version:2,welcom:15,which:13,write:13,yourself:13,zoo:18}}) Search.setIndex({docnames:["api_en/index_en","api_en/modules","api_en/paddleslim","api_en/paddleslim.analysis","api_en/paddleslim.common","api_en/paddleslim.core","api_en/paddleslim.dist","api_en/paddleslim.models","api_en/paddleslim.nas","api_en/paddleslim.nas.one_shot","api_en/paddleslim.pantheon","api_en/paddleslim.prune","api_en/paddleslim.quant","api_en/search_space_en","api_en/table_latency_en","index","index_en","install_en","intro_en","model_zoo_en","quick_start/distillation_tutorial_en","quick_start/index_en","quick_start/nas_tutorial_en","quick_start/pruning_tutorial_en","quick_start/quant_aware_tutorial_en","quick_start/quant_post_tutorial_en","tutorials/image_classification_sensitivity_analysis_tutorial_en","tutorials/index_en"],envversion:50,filenames:["api_en/index_en.rst","api_en/modules.rst","api_en/paddleslim.rst","api_en/paddleslim.analysis.rst","api_en/paddleslim.common.rst","api_en/paddleslim.core.rst","api_en/paddleslim.dist.rst","api_en/paddleslim.models.rst","api_en/paddleslim.nas.rst","api_en/paddleslim.nas.one_shot.rst","api_en/paddleslim.pantheon.rst","api_en/paddleslim.prune.rst","api_en/paddleslim.quant.rst","api_en/search_space_en.rst","api_en/table_latency_en.md","index.rst","index_en.rst","install_en.md","intro_en.md","model_zoo_en.md","quick_start/distillation_tutorial_en.md","quick_start/index_en.rst","quick_start/nas_tutorial_en.md","quick_start/pruning_tutorial_en.md","quick_start/quant_aware_tutorial_en.md","quick_start/quant_post_tutorial_en.md","tutorials/image_classification_sensitivity_analysis_tutorial_en.md","tutorials/index_en.rst"],objects:{"":{paddleslim:[2,0,0,"-"]},"paddleslim.analysis":{LatencyEvaluator:[3,1,1,""],TableLatencyEvaluator:[3,1,1,""],flops:[3,0,0,"-"],latency:[3,0,0,"-"],model_size:[3,0,0,"-"]},"paddleslim.analysis.LatencyEvaluator":{latency:[3,2,1,""]},"paddleslim.analysis.TableLatencyEvaluator":{latency:[3,2,1,""]},"paddleslim.analysis.flops":{flops:[3,3,1,""]},"paddleslim.analysis.latency":{LatencyEvaluator:[3,1,1,""],TableLatencyEvaluator:[3,1,1,""]},"paddleslim.analysis.latency.LatencyEvaluator":{latency:[3,2,1,""]},"paddleslim.analysis.latency.TableLatencyEvaluator":{latency:[3,2,1,""]},"paddleslim.analysis.model_size":{model_size:[3,3,1,""]},"paddleslim.common":{ControllerClient:[4,1,1,""],ControllerServer:[4,1,1,""],EvolutionaryController:[4,1,1,""],SAController:[4,1,1,""],cached_reader:[4,0,0,"-"],controller:[4,0,0,"-"],controller_client:[4,0,0,"-"],controller_server:[4,0,0,"-"],get_logger:[4,3,1,""],lock:[4,0,0,"-"],log_helper:[4,0,0,"-"],sa_controller:[4,0,0,"-"],unlock:[4,3,1,""]},"paddleslim.common.ControllerClient":{next_tokens:[4,2,1,""],request_current_info:[4,2,1,""],update:[4,2,1,""]},"paddleslim.common.ControllerServer":{close:[4,2,1,""],ip:[4,2,1,""],port:[4,2,1,""],run:[4,2,1,""],start:[4,2,1,""]},"paddleslim.common.EvolutionaryController":{next_tokens:[4,2,1,""],reset:[4,2,1,""],update:[4,2,1,""]},"paddleslim.common.SAController":{best_tokens:[4,4,1,""],current_tokens:[4,4,1,""],max_reward:[4,4,1,""],next_tokens:[4,2,1,""],update:[4,2,1,""]},"paddleslim.common.cached_reader":{cached_reader:[4,3,1,""]},"paddleslim.common.controller":{EvolutionaryController:[4,1,1,""]},"paddleslim.common.controller.EvolutionaryController":{next_tokens:[4,2,1,""],reset:[4,2,1,""],update:[4,2,1,""]},"paddleslim.common.controller_client":{ControllerClient:[4,1,1,""]},"paddleslim.common.controller_client.ControllerClient":{next_tokens:[4,2,1,""],request_current_info:[4,2,1,""],update:[4,2,1,""]},"paddleslim.common.controller_server":{ControllerServer:[4,1,1,""]},"paddleslim.common.controller_server.ControllerServer":{close:[4,2,1,""],ip:[4,2,1,""],port:[4,2,1,""],run:[4,2,1,""],start:[4,2,1,""]},"paddleslim.common.lock":{lock:[4,3,1,""],unlock:[4,3,1,""]},"paddleslim.common.log_helper":{get_logger:[4,3,1,""]},"paddleslim.common.sa_controller":{SAController:[4,1,1,""]},"paddleslim.common.sa_controller.SAController":{best_tokens:[4,4,1,""],current_tokens:[4,4,1,""],max_reward:[4,4,1,""],next_tokens:[4,2,1,""],update:[4,2,1,""]},"paddleslim.core":{GraphWrapper:[5,1,1,""],OpWrapper:[5,1,1,""],Registry:[5,1,1,""],VarWrapper:[5,1,1,""],graph_wrapper:[5,0,0,"-"],registry:[5,0,0,"-"]},"paddleslim.core.GraphWrapper":{"var":[5,2,1,""],all_parameters:[5,2,1,""],clone:[5,2,1,""],get_param_by_op:[5,2,1,""],infer_shape:[5,2,1,""],is_parameter:[5,2,1,""],is_persistable:[5,2,1,""],next_ops:[5,2,1,""],numel_params:[5,2,1,""],ops:[5,2,1,""],pre_ops:[5,2,1,""],program:[5,2,1,""],update_groups_of_conv:[5,2,1,""],update_param_shape:[5,2,1,""],vars:[5,2,1,""]},"paddleslim.core.OpWrapper":{all_inputs:[5,2,1,""],all_outputs:[5,2,1,""],attr:[5,2,1,""],idx:[5,2,1,""],inputs:[5,2,1,""],is_bwd_op:[5,2,1,""],is_opt_op:[5,2,1,""],outputs:[5,2,1,""],set_attr:[5,2,1,""],type:[5,2,1,""]},"paddleslim.core.Registry":{get:[5,2,1,""],module_dict:[5,4,1,""],name:[5,4,1,""],register:[5,2,1,""]},"paddleslim.core.VarWrapper":{inputs:[5,2,1,""],is_parameter:[5,2,1,""],name:[5,2,1,""],outputs:[5,2,1,""],set_shape:[5,2,1,""],shape:[5,2,1,""]},"paddleslim.core.graph_wrapper":{GraphWrapper:[5,1,1,""],OpWrapper:[5,1,1,""],VarWrapper:[5,1,1,""]},"paddleslim.core.graph_wrapper.GraphWrapper":{"var":[5,2,1,""],all_parameters:[5,2,1,""],clone:[5,2,1,""],get_param_by_op:[5,2,1,""],infer_shape:[5,2,1,""],is_parameter:[5,2,1,""],is_persistable:[5,2,1,""],next_ops:[5,2,1,""],numel_params:[5,2,1,""],ops:[5,2,1,""],pre_ops:[5,2,1,""],program:[5,2,1,""],update_groups_of_conv:[5,2,1,""],update_param_shape:[5,2,1,""],vars:[5,2,1,""]},"paddleslim.core.graph_wrapper.OpWrapper":{all_inputs:[5,2,1,""],all_outputs:[5,2,1,""],attr:[5,2,1,""],idx:[5,2,1,""],inputs:[5,2,1,""],is_bwd_op:[5,2,1,""],is_opt_op:[5,2,1,""],outputs:[5,2,1,""],set_attr:[5,2,1,""],type:[5,2,1,""]},"paddleslim.core.graph_wrapper.VarWrapper":{inputs:[5,2,1,""],is_parameter:[5,2,1,""],name:[5,2,1,""],outputs:[5,2,1,""],set_shape:[5,2,1,""],shape:[5,2,1,""]},"paddleslim.core.registry":{Registry:[5,1,1,""]},"paddleslim.core.registry.Registry":{get:[5,2,1,""],module_dict:[5,4,1,""],name:[5,4,1,""],register:[5,2,1,""]},"paddleslim.dist":{single_distiller:[6,0,0,"-"]},"paddleslim.dist.single_distiller":{fsp_loss:[6,3,1,""],l2_loss:[6,3,1,""],loss:[6,3,1,""],merge:[6,3,1,""],soft_label_loss:[6,3,1,""]},"paddleslim.models":{classification_models:[7,0,0,"-"],image_classification:[7,3,1,""],mobilenet:[7,0,0,"-"],mobilenet_v2:[7,0,0,"-"],resnet:[7,0,0,"-"],util:[7,0,0,"-"]},"paddleslim.models.classification_models":{MobileNet:[7,1,1,""],MobileNetV2:[7,1,1,""],ResNet34:[7,3,1,""],ResNet50:[7,3,1,""]},"paddleslim.models.classification_models.MobileNet":{conv_bn_layer:[7,2,1,""],depthwise_separable:[7,2,1,""],net:[7,2,1,""]},"paddleslim.models.classification_models.MobileNetV2":{conv_bn_layer:[7,2,1,""],inverted_residual_unit:[7,2,1,""],invresi_blocks:[7,2,1,""],net:[7,2,1,""],shortcut:[7,2,1,""]},"paddleslim.models.mobilenet":{MobileNet:[7,1,1,""]},"paddleslim.models.mobilenet.MobileNet":{conv_bn_layer:[7,2,1,""],depthwise_separable:[7,2,1,""],net:[7,2,1,""]},"paddleslim.models.mobilenet_v2":{MobileNetV2:[7,1,1,""],MobileNetV2_scale:[7,3,1,""],MobileNetV2_x1_0:[7,3,1,""],MobileNetV2_x1_5:[7,3,1,""],MobileNetV2_x2_0:[7,3,1,""]},"paddleslim.models.mobilenet_v2.MobileNetV2":{conv_bn_layer:[7,2,1,""],inverted_residual_unit:[7,2,1,""],invresi_blocks:[7,2,1,""],net:[7,2,1,""],shortcut:[7,2,1,""]},"paddleslim.models.resnet":{ResNet101:[7,3,1,""],ResNet152:[7,3,1,""],ResNet34:[7,3,1,""],ResNet50:[7,3,1,""],ResNet:[7,1,1,""]},"paddleslim.models.resnet.ResNet":{basic_block:[7,2,1,""],bottleneck_block:[7,2,1,""],conv_bn_layer:[7,2,1,""],net:[7,2,1,""],shortcut:[7,2,1,""]},"paddleslim.models.util":{image_classification:[7,3,1,""]},"paddleslim.nas":{one_shot:[9,0,0,"-"],sa_nas:[8,0,0,"-"]},"paddleslim.nas.one_shot":{OneShotSearch:[9,3,1,""],OneShotSuperNet:[9,1,1,""],SuperMnasnet:[9,1,1,""],one_shot_nas:[9,0,0,"-"],super_mnasnet:[9,0,0,"-"]},"paddleslim.nas.one_shot.OneShotSuperNet":{forward:[9,2,1,""],init_tokens:[9,2,1,""],range_table:[9,2,1,""]},"paddleslim.nas.one_shot.SuperMnasnet":{get_flops:[9,2,1,""],init_tokens:[9,2,1,""],range_table:[9,2,1,""]},"paddleslim.nas.one_shot.one_shot_nas":{OneShotSearch:[9,3,1,""],OneShotSuperNet:[9,1,1,""]},"paddleslim.nas.one_shot.one_shot_nas.OneShotSuperNet":{forward:[9,2,1,""],init_tokens:[9,2,1,""],range_table:[9,2,1,""]},"paddleslim.nas.one_shot.super_mnasnet":{SuperMnasnet:[9,1,1,""]},"paddleslim.nas.one_shot.super_mnasnet.SuperMnasnet":{get_flops:[9,2,1,""],init_tokens:[9,2,1,""],range_table:[9,2,1,""]},"paddleslim.nas.sa_nas":{SANAS:[8,1,1,""]},"paddleslim.nas.sa_nas.SANAS":{current_info:[8,2,1,""],next_archs:[8,2,1,""],reward:[8,2,1,""],tokens2arch:[8,2,1,""]},"paddleslim.pantheon":{Student:[10,1,1,""],Teacher:[10,1,1,""],student:[10,0,0,"-"],teacher:[10,0,0,"-"],utils:[10,0,0,"-"]},"paddleslim.pantheon.Student":{get_knowledge_desc:[10,2,1,""],get_knowledge_generator:[10,2,1,""],get_knowledge_qsize:[10,2,1,""],recv:[10,2,1,""],register_teacher:[10,2,1,""],send:[10,2,1,""],start:[10,2,1,""]},"paddleslim.pantheon.Teacher":{dump:[10,2,1,""],recv:[10,2,1,""],send:[10,2,1,""],start:[10,2,1,""],start_knowledge_service:[10,2,1,""]},"paddleslim.pantheon.student":{Student:[10,1,1,""]},"paddleslim.pantheon.student.Student":{get_knowledge_desc:[10,2,1,""],get_knowledge_generator:[10,2,1,""],get_knowledge_qsize:[10,2,1,""],recv:[10,2,1,""],register_teacher:[10,2,1,""],send:[10,2,1,""],start:[10,2,1,""]},"paddleslim.pantheon.teacher":{Teacher:[10,1,1,""]},"paddleslim.pantheon.teacher.Teacher":{dump:[10,2,1,""],recv:[10,2,1,""],send:[10,2,1,""],start:[10,2,1,""],start_knowledge_service:[10,2,1,""]},"paddleslim.pantheon.utils":{EndSignal:[10,1,1,""],StartSignal:[10,1,1,""],SyncSignal:[10,1,1,""],check_ip:[10,3,1,""],convert_dtype:[10,3,1,""]},"paddleslim.prune":{AutoPruner:[11,1,1,""],Pruner:[11,1,1,""],SensitivePruner:[11,1,1,""],auto_pruner:[11,0,0,"-"],conv2d:[11,1,1,""],flops_sensitivity:[11,3,1,""],get_ratios_by_loss:[11,3,1,""],load_model:[11,3,1,""],load_sensitivities:[11,3,1,""],merge_sensitive:[11,3,1,""],prune_io:[11,0,0,"-"],prune_walker:[11,0,0,"-"],pruner:[11,0,0,"-"],save_model:[11,3,1,""],sensitive:[11,0,0,"-"],sensitive_pruner:[11,0,0,"-"],sensitivity:[11,3,1,""]},"paddleslim.prune.AutoPruner":{prune:[11,2,1,""],reward:[11,2,1,""]},"paddleslim.prune.Pruner":{prune:[11,2,1,""]},"paddleslim.prune.SensitivePruner":{get_ratios_by_sensitive:[11,2,1,""],greedy_prune:[11,2,1,""],prune:[11,2,1,""],restore:[11,2,1,""],save_checkpoint:[11,2,1,""]},"paddleslim.prune.auto_pruner":{AutoPruner:[11,1,1,""]},"paddleslim.prune.auto_pruner.AutoPruner":{prune:[11,2,1,""],reward:[11,2,1,""]},"paddleslim.prune.prune_io":{load_model:[11,3,1,""],save_model:[11,3,1,""]},"paddleslim.prune.prune_walker":{conv2d:[11,1,1,""]},"paddleslim.prune.pruner":{Pruner:[11,1,1,""]},"paddleslim.prune.pruner.Pruner":{prune:[11,2,1,""]},"paddleslim.prune.sensitive":{flops_sensitivity:[11,3,1,""],get_ratios_by_loss:[11,3,1,""],load_sensitivities:[11,3,1,""],merge_sensitive:[11,3,1,""],sensitivity:[11,3,1,""]},"paddleslim.prune.sensitive_pruner":{SensitivePruner:[11,1,1,""]},"paddleslim.prune.sensitive_pruner.SensitivePruner":{get_ratios_by_sensitive:[11,2,1,""],greedy_prune:[11,2,1,""],prune:[11,2,1,""],restore:[11,2,1,""],save_checkpoint:[11,2,1,""]},"paddleslim.quant":{quant_embedding:[12,0,0,"-"],quanter:[12,0,0,"-"]},"paddleslim.quant.quant_embedding":{quant_embedding:[12,3,1,""]},"paddleslim.quant.quanter":{convert:[12,3,1,""],quant_aware:[12,3,1,""],quant_post:[12,3,1,""]},paddleslim:{analysis:[3,0,0,"-"],common:[4,0,0,"-"],core:[5,0,0,"-"],dist:[6,0,0,"-"],models:[7,0,0,"-"],pantheon:[10,0,0,"-"],prune:[11,0,0,"-"],quant:[12,0,0,"-"],version:[2,0,0,"-"]}},objnames:{"0":["py","module","Python module"],"1":["py","class","Python class"],"2":["py","method","Python method"],"3":["py","function","Python function"],"4":["py","attribute","Python attribute"]},objtypes:{"0":"py:module","1":"py:class","2":"py:method","3":"py:function","4":"py:attribute"},terms:{"769x769":19,"94mb":[16,18],"\u4e2d\u6587\u6587\u6863":16,"\u5728\u53e6\u4e00\u4e2a\u8fdb\u7a0b\u4e2d":26,"abstract":[3,4],"class":[3,4,5,7,8,9,10,11,13],"default":[3,4,6,8,9,10,11,12,20,24],"final":[9,12,22,24,25,26],"float":[3,4,5,6,8,11,14,22,24],"function":[4,5,6,8,9,11,12,13,14,20,23,24,25],"import":[4,13],"int":[3,4,5,8,9,10,11,12,14],"new":[4,5,13],"public":10,"return":[3,4,5,6,8,9,10,11,12,13,22,26],"static":[10,16,18],"super":9,"true":[3,7,8,10,11,12,20,22,23,24,25,26],"try":[4,11],"var":[5,6,24,25],"while":[8,9,11,26],And:[11,23],But:26,FPS:19,For:[4,8,13],NOT:13,One:[16,18,26],Ops:20,The:[3,4,5,6,8,9,10,11,12,14,19,20,22,23,24,25,26],Then:[24,25],There:25,Use:13,Used:14,__dict__:20,__init__:13,__name__:4,_bn:13,_conv0:13,_conv1:13,_conv2:13,_conv:13,_conv_bn_lay:13,_elementwise_add:13,_resnet_block:13,_sep_weight:26,_shortcut:13,_vd:19,aadvanc:16,abil:[16,18],about:[0,8,13],abs:13,abs_max:12,acc1:[20,22,23,24,25,26],acc5:[20,22,23,24,25,26],acc:19,acc_top1:[20,22,26],acc_top1_n:26,acc_top5:[20,22,26],acc_top5_n:26,accept:[9,11],accord:[4,5,8,11,13,22,24,26],accuraci:[11,16,18,20,22,24,25,26],accuracy_loss:11,act:[7,13],activ:[12,14,25],activation_bit:12,active_typ:14,adam:22,add:[3,6,12,13,24],added:[6,10],address:[4,8,10],advanc:[16,18],after:[4,5,22,25,26],again:11,agent:4,algo:12,algorithm:8,all:[3,4,5,6,8,10,11,12,14,20],all_input:5,all_output:5,all_paramet:[5,26],alreadi:10,also:[11,16,18,20,26],analysi:[0,1,2,22,23,26],analysis:11,analyz:26,android:[16,18],ani:[5,10],anneal:[4,8,11],anoth:26,apart:26,api:[12,16,18,20,22,23,24,25,26],append:[11,13,20,22,24,25,26],appli:[12,16,18,26],applic:[16,18],arch:22,architectur:[4,8,13,14,20,21],arg:8,argument:[9,10,11],armv7:19,armv8:19,arrai:[13,22,24,25,26],arxiv:13,asctim:4,assembl:[16,18],assign:10,attr:5,attribut:5,auto:19,auto_prun:[1,2],autom:[16,18],automat:[4,16,18],autoprun:11,auxiliari:[16,18],avail:[16,17,18],averag:14,avg_cost:[20,22],avoid:20,awar:[16,18,21],axi:[13,14,22],backup:11,backward:5,base:[3,4,5,8,9,10,11,13,16,18,19,22,23,26],baselin:[16,18,19],basic_block:7,basicconfig:4,batch:[10,12,14,16,18,20,22,23,24,25,26],batch_gener:10,batch_norm:13,batch_num:[12,25],batch_reward:22,batch_siz:[10,12,20,22,23,24,25,26],becaus:[24,25],befor:[4,6,12,26],below:[11,20,23,26],benckmark:[16,18],best:[4,8,9,11],best_token:4,better:8,between:[11,12],beyond:19,bia:14,bigger:8,bind:4,bit:12,blazefac:19,blob:13,block:[8,13],block_mask:[8,13],block_num:[8,13],bn5c_branch2b:20,bool:[3,5,8,10,11,12],bottleneck_block:7,bottleneck_params_list:13,box:19,bracket:12,buf_siz:[10,22],buffer:10,build_program:22,c_in:14,c_out:14,cach:4,cache_dir:12,cache_path:4,cached_id:4,cached_read:[1,2],calcul:[3,11,12,25],calibr:[12,25],call:[9,10,24,25,26],callback:[4,9,11],can:[5,8,10,11,12,13,14,16,18,20,24,26],cann:11,cannot:24,capac:10,carri:10,categori:20,caus:20,ceil:14,ceil_mod:14,cellphon:[16,18],certain:8,certainli:8,ch_out:7,chang:[23,24],change_depth:7,channel:[7,9,11,13,14,16,18,21],channel_in:13,channel_num:13,chapter:22,check:4,check_ip:10,checkpoint:[4,8,11],cifar10:[19,22],cifar:22,cityscap:19,class_dim:[7,20],class_num:7,classif:[21,27],classification_model:[1,2],classsif:[23,26],client:[4,11],client_nam:4,client_num:4,clip:12,clone:[5,17,22],close:[4,24,25],cls:5,coco:19,code:[13,20,23,26],collect:[13,16,18],com:[13,17],combin:6,comma:14,command:10,common:[1,2,10],commun:11,compiledprogram:12,compress:[16,18],comput:[9,11,14,16,18],condit:11,config:[4,8,10,12,13,19,22],configur:[8,24],conflict:20,connect:[4,11],consid:11,consist:[6,8],constrain:[16,18],constrain_func:4,constraint:[4,22],construct:[13,24,25],consult:[16,18],contain:[9,10,16,18,22,24,25],continu:22,control:[1,2,8,11],control_token:4,controller_cli:[1,2],controller_serv:[1,2],controllercli:4,controllerserv:4,conv1:7,conv1_nam:7,conv2_1_sep_weight:23,conv2_2_sep_weight:23,conv2d:[11,12,13],conv:13,conv_bn_lay:[7,13],conveni:[24,25],converg:8,convert:[8,12,24],convert_dtyp:10,convlut:3,convolut:[3,5,11,13,16,18,26],convolutoin:26,core:[1,2],correctli:[20,22,23,24,25,26],correspind:8,correspond:[8,10,14,20],cost:[16,18,19,20,22,26],count:[3,4,26],cpu:10,cpu_num:10,cpuplac:[6,11,12,20,22,23,24,25],creat:14,criterion:[11,19],cross_entropi:[20,22],cuda_visible_devic:10,cudaplac:[6,11,12,26],current:[3,4,5,8,9,11,13,22,26],current_flop:22,current_info:8,current_token:4,cut:11,cycl:22,dark:[16,18],dart:19,darts_sa:19,data:[4,8,10,12,16,18,20,23],data_feed:[22,26],data_map_map:6,data_name_map:[6,20],data_read:22,data_residu:7,datafeed:[20,22,23,24,25,26],dataload:[10,12],dataset:[4,11,19,20,22,24,25,26],dcn:19,decai:[4,11],decor:13,decoupl:[16,18],deep:[16,18],deeplabv3:19,def:[13,22,24,25,26],defalut:[11,12],default_main_program:22,defin:[3,4,5,6,9,10,13,16,18,24,25],delimit:3,demo:[20,23,26],denot:10,depend:[14,24,25],depthwise_conv2d:12,depthwise_conv2d_11:20,depthwise_separ:7,dequant:[12,24],describ:22,descript:10,detail:[3,8,14,19],determin:10,develop:[13,16,18],devic:[3,6,10,11,12,16,18,19],dict:[3,4,5,6,8,10,11,12],dictionari:[8,10],differ:[10,13,16,18],differenct:11,dilat:14,dimens:6,direct:12,directli:22,directori:[8,11,26],dirnam:[11,24,25],disabl:4,discret:8,disk:12,dist:[0,1,2,20],distil:6,distillationresnet34:[16,18],distribut:[16,18],divergenc:12,divid:6,document:16,doe:[24,25],doesn:10,doing:25,donnot:4,donot:14,down:[11,26],download:[19,20,22,23,24,25,26],drop:10,drop_last:[10,20,23,24,25,26],dtype:[10,12,20,22,24],dump:10,dure:[8,16,18,26],dygraph:9,dynam:[9,10,16,18],each:[3,9,10,11,16,18,22],easi:19,easier:[16,18],easili:23,either:[16,18],element:[5,11],elementwise_add:13,els:[4,13],empir:19,emsp:13,end:10,endsign:10,engin:[3,14],english:14,enough:26,ensur:[17,20,23,26],enumer:13,env:19,environ:[10,14],epoch:[20,22,23,24,25,26],equal:11,estim:[16,18],eva:26,eval_feed:22,eval_func:[9,11],eval_progarm:22,eval_program:[11,22],eval_read:[4,22],evalu:[3,4,11,14,26],everi:[9,12,13,14],evolut:[16,18],evolutionari:4,evolutionarycontrol:4,exampl:[4,13,24,25],except:6,exclud:14,excut:[20,23,26],exe:[10,11,20,22,23,24,25,26],execut:[9,10,11,26],executor:[10,11,12,20,22,24,25],exist:13,expansion_factor:7,experi:[8,22],explor:[8,16,18],extrem:8,face:19,factor:12,failur:8,fake:12,fals:[3,5,7,8,9,10,11,12,22,23,24],fast:19,faster:8,fc_name:7,featur:14,feed:[10,20,22,23,24,25,26],feed_list:10,feed_target_nam:25,feeded_var_nam:[24,25],fetch:10,fetch_list:[20,22,23,24,25,26],fetch_target:25,file:[3,4,5,10,11,12,13,14,16,18,19],filenam:12,filesystem:[11,26],filter:[5,11],filter_num:13,filter_s:[7,13],finally_reward:22,finetun:24,finish:10,first:[8,14,24,25],fit:20,flag_bia:14,flag_global_pool:14,flag_relu:14,flags_selected_gpu:10,flexibl:[16,18],float32:[20,22,24],float_prog:24,floor:14,flop:[1,2,11,13,16,18,22,26],flops_sensit:11,fluid:[3,5,6,9,10,11,12,13,20,22,23,24,25,26],fmt:4,follow:[10,13,14,20,22,23,24,25,26],for_test:[5,12,22,24],form:20,formal:[24,25],format:[3,4,8,9,10,11,13,20,22,23,24,26],forward:[9,25],fp32:[12,19],framework:[5,16,18,24,25],freez:12,freezed_program:12,freezed_program_int8:12,friendli:[16,18],from:[4,5,6,10,11,13,16,17,18,20,22,24,26],fsp:6,fsp_loss:6,fuction:26,func:10,furthermor:[16,18],gener:[4,8,9,10,11,12],get:[3,4,5,8,9,10,11,12,13,20,22,24,25],get_flop:9,get_knowledge_desc:10,get_knowledge_gener:10,get_knowledge_qs:10,get_logg:4,get_param_by_op:5,get_ratios_by_loss:[11,26],get_ratios_by_sensit:11,gflop:19,git:17,github:[13,17],given:[3,4,5,11,26],global:[6,14],global_block:[24,25,26],global_scop:[12,23,26],gpu:[10,19],granular:26,graph:[3,5,9,10,11],graph_wrapp:[1,2],graphwrapp:5,grapwrapp:3,greater:8,greedi:8,greedy_prun:11,group:[5,7,11,14,26],guard:20,h_in:14,handl:4,hard:19,hardwar:[0,16,18],has:[8,13,14],have:[17,20,22,23,24,25,26],head:13,height:14,higher:[8,13],histori:17,host:[8,11],how:[8,17,20,22,23,24,25,26],http:[13,17],human:5,hyperparamet:[4,16,18],ident:11,identifi:4,ids:10,idx:5,if_act:7,ifshortcut:7,ignor:10,imag:[21,27],image_classif:[7,13,23,24,25,26],image_shap:7,imagenet1000:19,imagenet2012:[16,18],implement:[16,18],in_address:10,in_c:7,in_nod:5,in_path:10,inception_v4:13,inceptionablock:13,inceptionablockspac:13,inceptioncblock:13,inceptioncblockspac:13,includ:[5,8,10,14,22],independ:[16,18],index:[13,14],indic:[5,6,9,19],infer:[3,10,12,14,16,18,24,25],infer_shap:5,inference_model:[24,25],inferfac:[24,25],info:4,inform:[4,8,11,14,26],inherit:13,init:[4,9,11],init_ratio:11,init_temperatur:[4,8,11],init_token:[4,8,9,13],initi:[4,8,13],input:[5,6,7,8,9,10,12,13,14,19,20,23,26],input_channel:9,input_data:22,input_s:[8,13],insert:12,instal:[16,20,22,23,24,25,26],instanc:[5,8,9,11],int64:[20,22],int8:[12,16,18,24],int8_prog:24,integ:9,interfac:6,introduct:19,inverted_residual_unit:7,invresi_block:7,iphon:[16,18],irgraph:5,is_bwd_op:5,is_first:7,is_full_quant:12,is_opt_op:5,is_paramet:5,is_persist:5,is_serv:[8,11],is_use_cache_fil:12,iter:[4,11,24,25],iterm:13,its:[10,14,26],jump:22,just:[3,23,26],keep:[16,18],kei:[3,4,5,6,8,10,11,12,20,26],kernel:[13,14],kirin:19,knowledg:10,kwarg:6,l140:13,l148:13,l173:13,l174:13,l1_norm:11,l291:13,l29:13,l2_loss:[6,20],l30:13,label:[6,20,22],languag:[12,16,18],lantenc:0,larg:[8,16,18],last:[4,10],latenc:[1,2,11,13,14,16,18,19],latency_855:19,latencyevalu:3,latest:[4,11,16,18],launch:10,layer:[3,5,7,9,13,16,18,20,22,26],layer_set:13,lazi:11,learn:[20,23,24,26],learning_r:22,least:9,legal:[4,11],len:13,length:[8,11,13],less:[8,10,11],level:[4,10],levelnam:4,librari:11,light:4,limit:10,line:[14,20],lis:9,list:[4,5,8,9,10,11,12,13],list_var:20,listen:4,lite:[19,24],load:[5,8,11,12,24,25],load_checkpoint:8,load_inference_model:25,load_model:11,load_sensit:[11,26],local:[4,16,18],lock:[1,2],lod:10,log:4,log_help:[1,2],logger:4,lookup_t:12,loss:[6,11,22,23,24,25,26],loss_func:6,loss_np:20,lower:8,mai:26,main:20,main_program:[24,25],make:[16,18,22,23,24,25,26],map:[6,12,14,16,18],mark:14,max:[4,11,14],max_client_num:[4,11],max_ratio:11,max_reward:4,max_try_tim:[4,11],max_valu:9,maximum:[4,9,10],mean:[4,8,9,10,11,13,20,22,24,25,26],meanwhil:[16,18],medium:19,meet:4,memori:12,merg:[6,10,11,16,18],merge_sensit:[11,26],merge_strategi:10,messag:4,method:[3,4,10,12,16,18,19,20,24,25],min:11,min_ratio:11,min_valu:9,mini:25,minim:[19,20,22],minimum:9,miou:19,mixup:19,mnist:[20,23,24,25,26],mobilenet:[1,2,19,20,23,24,25,26],mobilenet_v1:13,mobilenet_v2:[1,2,13],mobilenetv1:[16,18,19,20,23,24,25,26],mobilenetv1block:13,mobilenetv1blockspac:13,mobilenetv1spac:13,mobilenetv2:[7,13,16,18,19,22],mobilenetv2_na:19,mobilenetv2_scal:7,mobilenetv2_x1_0:7,mobilenetv2_x1_5:7,mobilenetv2_x2_0:7,mobilenetv2block:13,mobilenetv2blockspac:13,mobilenetv2spac:[13,22],mobilnetv1:13,mode:[3,9,10,16,18],model:[1,2,3,6,8,9,10,11,12,13,21,27],model_dir:[12,25],model_filenam:12,model_s:[1,2],models:19,modifi:11,modul:1,module_dict:5,momentum:20,monitor:10,more:[8,12,16,18,20,26],much:8,mul:[3,12],multi:14,multipl:[10,16,18],must:[11,12],n_in:14,naiv:[16,18],name:[3,4,5,6,7,8,9,10,11,12,13,14,20,22,23,24,25],name_prefix:[6,20],name_scop:9,namespac:13,nas:[0,1,2,4,22],nas_checkpoint:8,nasv2:19,necessari:[10,13,22,26],need:[8,13,20,22,24,25],nerual:21,net:[7,9,20],net_arch:13,network:[8,9,11,20],neural:[4,8,13,22],never:4,next:[4,5,8,22],next_arch:[8,22],next_op:5,next_token:4,node:[5,10,16,18],none:[4,5,6,7,8,9,10,11,12,13,14,20,22],normal:8,note:[8,19,23,24,25,26],now:10,num_filt:[7,13],num_filters1:7,num_filters2:7,num_group:7,num_in_filt:7,number:[3,4,5,8,10,11,12,13,14,20,23,26],numeb:13,numel_param:5,numpi:[13,22,24,25,26],obj365_pretrain:19,object:[3,4,5,8,10,11],observ:20,obtain:[8,12],offlin:[10,16,18],onc:10,one:[9,10,14,20,24,25,26],one_shot:[0,2,8],one_shot_na:[2,8],oneshotsearch:9,oneshotsupernet:9,onli:[3,8,10,11,12,13,24,25],onlin:[10,16,18],only_conv:3,only_graph:[11,26],op_typ:14,open:[16,18],oper:[3,5,12,20,24],ops:5,opt:20,optim:[5,14,20,22],option:[12,14,26],opwrapp:5,order:[10,20,22,24,25],org:[13,17],origin:13,other:[6,10,26],otherwis:[3,9,12],out:[10,20],out_channel:9,out_nod:5,out_path:10,out_port:10,output:[4,5,8,9,10,14,20,22,23,24,25,26],output_s:[8,13],overwrit:13,packag:[0,1,17,20,23,26],pad:[7,13,14],paddl:[4,5,6,9,11,16,18,20,22,23,24,25,26],paddle1:[20,23,24,25,26],paddlecv:13,paddlelit:19,paddlepaddl:[13,17],paddlepaddle1:17,paddleslim:[0,14,16,17,18,20,22,23,24,25,26],pair:10,pantheon:[0,1,2,16,18],paper:[13,16,18],param:[4,8,11,12,19,23,26],param_backup:11,param_nam:11,param_shape_backup:11,paramat:11,paramet:[3,4,5,6,8,9,10,11,12,14,23,24,25],params_filenam:12,params_nam:12,pars:10,partial:4,pasacl:19,pascal:19,path:[3,4,10,12],pdf:13,percent:11,percis:13,perform:[3,9,20,24,25,26],persist:5,pickl:11,pip:17,place:[6,11,12,22,23,24,26],platform:[16,18],pleas:[8,17,19,20,22,23,24,25,26],plu:10,pool_typ:14,pop:10,port:[4,8,10,11,16,18],posit:9,possibl:[8,14],post:[12,16,18,21],pre:[19,22,24,25],pre_op:5,precis:12,predict:[10,16,18,20],prefix:[6,20],prefix_nam:7,preform:[24,25],prelu:14,preserv:8,pretrain:26,previou:5,primit:[16,18],print:[20,22,23,24,25,26],probabl:8,process:[13,16,18,24,25],prog:[24,25],program:[3,5,6,10,11,12,16,18,24,25,26],program_guard:[20,22],provid:[12,16,18],prun:[16,18],prune:[0,1,2,5,21,27],prune_io:[1,2],prune_walk:[1,2],pruned_flop:11,pruned_flops_r:11,pruned_lat:11,pruned_param:11,pruned_program:[11,23,26],pruned_ratio:[11,26],pruned_val_program:26,pruner:[1,2,23,26],prunework:11,purpos:13,push:10,pypi:17,pyread:10,python:[10,12,13,17],qsize:10,qualcomm:19,quant:[0,1,2,24,25],quant_awar:[12,19,24],quant_embed:[1,2],quant_post:[12,19,25],quant_post_model:25,quant_post_prog:25,quant_program:24,quanter:[1,2],quantiz:[12,21],quantizable_op_typ:12,quantize_bit:12,quantize_model_path:[12,25],quantize_typ:12,queue:10,quick:16,quickli:26,r34:19,r50:19,random:[4,8],randomli:8,rang:[4,8,9,13,14,16,18,22,24],range_t:[4,9,13],rank:14,rate:[4,8,11,24],ratio:[11,23],reach:[10,24,25],read:[20,22,23,24,25,26],readabl:5,reader:[4,10,20,22,23,24,25],reader_config:10,real:10,reason:[24,25,26],receiv:10,reciev:10,record:[3,12],recv:10,reduc:8,reduce_r:[4,8,11],reduct:8,refer:[8,13,16,18,19],regist:[5,10,13],register_teach:10,registr:10,registri:[1,2],relu6:14,relu:[7,13,14],rememb:4,remov:26,repeat:[10,13],repeat_tim:9,repeatedli:26,repres:[6,9,12,13,14],request:4,request_current_info:4,res:[24,25],research:[16,18],reset:4,resnet101:[7,19],resnet152:7,resnet34:[7,16,18,19],resnet50:[7,16,18,19,20],resnet50_vd1:19,resnet50_vd:19,resnet:[1,2,13,16,18],resnet_lay:13,resnetblock:13,resnetblockspac:13,resnetblockspace2:13,resnetspac:13,respect:10,restor:11,result:[24,25,26],reward:[4,8,11,22],reward_avg:22,risk:19,rk3288:[16,18],rtype:8,run:[4,6,10,12,16,18,20,22,23,24,25,26],s_0:26,s_1:26,sa_control:[1,2],sa_na:[1,2],sacontrol:4,same:[4,10,12,13,16,18,20],sampl:[4,10,12,16,18],sample_gener:[10,12,25],sample_list_gener:10,sampled_r:4,sana:[4,8,13,19],satisfi:22,save:[4,8,11,12,14,25,26],save_checkpoint:[8,11,22],save_inference_model:[12,24,25],save_int8:[12,24],save_model:11,scalabl:[16,18],scalar:11,scale:[7,12,16,18,25],scene:4,schema:10,scnn:19,scope:[5,6,9,11,12],score:[8,11],search:[0,4,8,9,11,21],search_space_bas:13,search_space_registri:13,search_step:[4,8,9,11],searcher:4,searchspac:13,searchspacebas:13,second:6,section:[22,23,24,25,26],see:[10,20],segment:[16,18],select:[24,25],self:[6,13,16,18],semant:[16,18],send:10,sens_0:26,sens_1:26,sensit:[1,2,16,18,19,27],sensitive_prun:[1,2],sensitiveprun:11,sensitivities_0:26,sensitivities_1:26,sensitivities_fil:[11,26],sent:10,separ:12,serv:10,server:[4,8,11],server_addr:[8,11,22],server_ip:4,server_port:4,servic:10,set:[4,5,8,9,10,11,12,13,26],set_attr:5,set_shap:5,sett:4,setup:17,shape:[5,10,11,13,20,22,23,26],share:10,shortcut:7,shortcut_conv:13,shot:[9,16,18],should:[4,6,9,10,11,12,24,26],show:[22,24,25,26],shuffl:22,sigmoid:14,similar:12,simpl:[17,23,26],simplifi:[24,25],simul:[4,8,11],simultan:4,singl:[11,12],single_distil:[1,2],size:[3,8,10,12,13,14,16,18,19,22,24,25],slim:[4,5,20,22,23,24,25,26],slow:26,slower:8,small:[8,16,18,24,25,26],smaller:[8,13,24],snapdragon:19,socket:4,soft:6,soft_label_loss:6,softmax:[6,22],softmax_out:22,solut:[4,16,18],some:[3,5,11,16,18,26],some_batch_genr:10,some_sample_gener:10,some_sample_list_gener:10,sort:11,sourc:[4,17],space:[0,4,8,9],special:[5,14],specifi:[6,10,13,20],speed:[19,24,25,26],split:[14,26],stabl:8,stage:9,start:[4,8,10,16,26],start_ev:22,start_knowledge_servic:10,start_train:22,startsign:10,startup_program:22,state:8,statu:4,steadi:8,step3:22,step:[4,8,9,11,22],stop:4,store:[11,23],str:[3,4,5,6,8,9,10,11,12,14],strategi:[9,10,11,16,18],stride:[7,9,13,14],string:[2,8,14],strong:8,strore:11,structur:[24,25],student:[1,2,6,16,18,19,20],student_feature_map:6,student_model_var:20,student_program:6,student_startup:20,student_temperatur:6,student_var1:6,student_var1_nam:6,student_var2:6,student_var2_nam:6,student_var:[6,20],student_var_nam:6,sub:[8,9],submodul:1,subpackag:1,successfulli:8,suffix:19,suggest:8,suitabl:24,sum:10,super_mnasnet:[2,8],supermnasnet:9,support:[10,11,12,14,16,18,26],sure:22,survei:[16,18],sychron:10,synchron:10,syncsign:10,system:4,tab:14,tabl:[0,4,9],table_fil:3,tablelatencyevalu:3,tanh:14,target:[3,5,11],target_var:[24,25],task:[4,8,16,18,23,26],tcp:[16,18],teacher:[1,2,6,16,18,19,20],teacher_:6,teacher_bn5c_branch2b:20,teacher_feature_map:6,teacher_id:10,teacher_model:20,teacher_model_var:20,teacher_program:6,teacher_startup:20,teacher_temperatur:6,teacher_var1:6,teacher_var1_nam:6,teacher_var2:6,teacher_var2_nam:6,teacher_var:[6,20],teacher_var_nam:6,technolog:[16,18],temp:12,temp_post_train:12,temperatur:[4,6,8,11],tensor:[5,12],tensorrt:19,test10:22,test:[11,12,19,20,22,23],test_program:22,test_read:[24,25,26],text:14,than:[8,10,11,16,18],thei:[16,18,24,25],them:[4,10,16,18],thi:[5,6,8,10,11,12,14,20,22,23,24,25,26],thread1:19,thread2:19,thread4:19,thread:[10,19],three:10,threshold:[11,12],time:[4,10,12,14,16,18,19,20,26],timestamp:14,tlatenc:14,tmp_0:20,tmp_3:20,token2arch:13,token:[4,8,9,11,13,19],tokens2arch:8,toolkit:[16,18],top1:[16,18,24,25],top5:[24,25],top:19,topk:11,total:[3,4,9],train10:22,train:[9,11,12,16,18,19,21],train_feed:[20,22,23,24,25],train_program:[11,22,23,24,25,26],train_read:[20,22,23,24,25,26],transfer:[10,16,18],transform:13,trial:10,tupl:[3,8,9,11,12],tutori:[16,20,22,23,24,25,26],two:20,txt:19,type:[3,4,5,6,8,9,10,11,12,14],uncom:20,under:12,unifi:20,uniform:[6,11,16,18,19],uniqu:10,unique_nam:20,univers:[16,18],unlock:4,unrel:10,unstabl:8,until:10,updat:[4,5,8,11],update_groups_of_conv:5,update_param_shap:5,usabl:4,use:[4,5,8,12,14,20,22,23,24,25,26],use_auxhead:9,use_cudnn:[7,22],use_gpu:[7,23,24,25,26],used:[3,4,5,6,8,9,10,11,12,13,14,22,23,24,26],user:[5,6,12],uses:[12,19,22],using:[4,12,14,24,25,26],usual:12,util:[1,2,12],v100:19,val_program:[23,24,25,26],val_quant_program:24,valid:[5,10],valu:[3,5,6,8,9,10,11,20,23,26],varaibl:9,variabl:[5,6,9,10,11,12,20],varibal:5,variou:[16,18],varwrapp:5,verifi:20,version:[1,19],vgg:[16,18],via:[16,18],vision:[16,18],visit:11,voc:19,volum:19,w_in:14,wai:14,wait:10,want:[8,13,22],weight:[11,12],weight_0:11,weight_1:11,weight_bit:12,well:[12,24,25],what:22,when:[10,11,12,24,25,26],whenev:10,where:[6,11,20],whether:[3,4,5,8,10,11,12,14],which:[4,6,8,9,11,12,20,22,24,25],whose:[3,9,10,11],why:8,wider:19,width:14,wise:[16,18],without:[4,24,25],won:26,work:[16,18],workflow:[20,23,26],wors:8,would:11,wrapper:[4,5,10],writer:10,wrote:10,yet:10,yolov3:19,you:[8,13,17,20,22,23,24,25,26],your:[16,18],yourself:8,zero:11,zoo:16},titles:["API Documents","paddleslim","paddleslim package","paddleslim.analysis package","paddleslim.common package","paddleslim.core package","paddleslim.dist package","paddleslim.models package","paddleslim.nas package","paddleslim.nas.one_shot package","paddleslim.pantheon package","paddleslim.prune package","paddleslim.quant package","search space","Table about hardware lantency","\u4e2d\u6587\u6587\u6863","Index","Install","Introduction","Model Zoo","Knowledge Distillation for Image Classification","Quick Start","Nerual Architecture Search for Image Classification","Channel Pruning for Image Classification","Training-aware Quantization of image classification model - quick start","Post-training Quantization of image classification model - quick start","Pruning of image classification model - sensitivity","Aadvanced Tutorials"],titleterms:{"\u4e2d\u6587\u6587\u6863":15,"function":[22,26],"import":[20,22,23,24,25,26],NAS:[16,18,19],aadvanc:27,about:[14,22],activaiton:14,add:20,after:[23,24],analysi:3,api:0,architectur:[16,18,22,24,25],auto_prun:11,awar:24,batch_norm:14,bofor:23,build:[22,23,26],cached_read:4,channel:23,classif:[16,18,19,20,22,23,24,25,26],classification_model:7,coco:[16,18],common:4,comput:[23,26],control:4,controller_cli:4,controller_serv:4,conv2d:14,core:5,data:[22,24,25,26],dataset:[16,18,23],defin:[20,22,23,26],definit:[24,25],depend:[20,22,23,26],detect:[16,18,19],dist:6,distil:[16,18,19,20],document:0,each:26,eltwis:14,evalu:22,exampl:22,expand:26,featur:[16,18,20],fetch:22,file:26,fix:[16,18],flop:[3,23],format:14,full:22,funciton:22,gener:26,get:26,graph_wrapp:5,hardwar:14,how:13,imag:[16,18,19,20,22,23,24,25,26],index:16,initi:22,input:[22,24,25],instal:17,instanc:22,introduc:14,introduct:[16,18],knowledg:[16,18,20],lantenc:14,latenc:3,load:26,lock:4,log_help:4,loss:20,map:20,merg:[20,26],mobilenet:[7,16,18],mobilenet_v2:7,model:[7,16,18,19,20,22,23,24,25,26],model_s:3,modul:[2,3,4,5,6,7,8,9,10,11,12],multi:26,name:26,nas:[8,9,13],necessari:[24,25],nerual:22,network:26,neural:[16,18],normal:[24,25],object:[16,18,19],one_shot:9,one_shot_na:9,oper:14,overview:14,packag:[2,3,4,5,6,7,8,9,10,11,12],paddleslim:[1,2,3,4,5,6,7,8,9,10,11,12,13],pantheon:10,paramet:26,pascal:[16,18],perform:[16,18],point:[16,18],pool:14,post:25,process:26,program:[20,22],provid:13,prune:[11,16,18,19,23,26],prune_io:11,prune_walk:11,pruner:11,quant:12,quant_embed:12,quanter:12,quantiz:[16,18,19,24,25],quick:[21,24,25],ratio:26,reader:26,registri:5,resnet:7,retur:22,sa_control:4,sa_na:8,sana:22,save:24,score:22,search:[13,16,18,22],segment:19,select:20,sensit:[11,26],sensitive_prun:11,sensitivi:26,singl:26,single_distil:6,softmax:14,space:13,start:[21,22,24,25],student:10,student_program:20,submodul:[2,3,4,5,6,7,8,9,10,11,12],subpackag:[2,8],super_mnasnet:9,tabl:14,teacher:10,teacher_program:20,test:[24,25,26],train:[20,22,23,24,25,26],tutori:27,use:13,util:[7,10],version:[2,14],voc:[16,18],which:13,write:13,yolov3:[16,18],yourself:13,zoo:19}})
\ No newline at end of file \ No newline at end of file
<!DOCTYPE html>
<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]-->
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>SANAS进阶版实验教程-压缩DARTS产出模型 &mdash; PaddleSlim 1.0 文档</title>
<link rel="stylesheet" href="../_static/css/theme.css" type="text/css" />
<link rel="index" title="索引"
href="../genindex.html"/>
<link rel="search" title="搜索" href="../search.html"/>
<link rel="top" title="PaddleSlim 1.0 文档" href="../index.html"/>
<link rel="up" title="进阶教程" href="index.html"/>
<link rel="next" title="目标检测模型蒸馏教程" href="paddledetection_slim_distillation_tutorial.html"/>
<link rel="prev" title="图像分类模型通道剪裁-敏感度分析" href="image_classification_sensitivity_analysis_tutorial.html"/>
<script src="../_static/js/modernizr.min.js"></script>
</head>
<body class="wy-body-for-nav" role="document">
<div class="wy-grid-for-nav">
<nav data-toggle="wy-nav-shift" class="wy-nav-side">
<div class="wy-side-scroll">
<div class="wy-side-nav-search">
<a href="../index.html" class="icon icon-home"> PaddleSlim
</a>
<div role="search">
<form id="rtd-search-form" class="wy-form" action="../search.html" method="get">
<input type="text" name="q" placeholder="Search docs" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
</div>
</div>
<div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
<ul class="current">
<li class="toctree-l1"><a class="reference internal" href="../index_en.html">English Documents</a></li>
<li class="toctree-l1"><a class="reference internal" href="../intro.html">介绍</a></li>
<li class="toctree-l1"><a class="reference internal" href="../install.html">安装</a></li>
<li class="toctree-l1"><a class="reference internal" href="../quick_start/index.html">快速开始</a></li>
<li class="toctree-l1 current"><a class="reference internal" href="index.html">进阶教程</a><ul class="current">
<li class="toctree-l2"><a class="reference internal" href="image_classification_sensitivity_analysis_tutorial.html">图像分类模型通道剪裁-敏感度分析</a></li>
<li class="toctree-l2 current"><a class="current reference internal" href="#">SANAS进阶版实验教程-压缩DARTS产出模型</a><ul>
<li class="toctree-l3"><a class="reference internal" href="#id1">收益情况</a></li>
<li class="toctree-l3"><a class="reference internal" href="#id2">搜索教程</a><ul>
<li class="toctree-l4"><a class="reference internal" href="#id3">1. 构造搜索空间</a></li>
<li class="toctree-l4"><a class="reference internal" href="#id4">2. 引入依赖包并定义全局变量</a></li>
<li class="toctree-l4"><a class="reference internal" href="#sanas">3. 初始化SANAS实例</a></li>
<li class="toctree-l4"><a class="reference internal" href="#id5">4. 定义计算模型参数量的函数</a></li>
<li class="toctree-l4"><a class="reference internal" href="#id6">5. 定义网络输入数据的函数</a></li>
<li class="toctree-l4"><a class="reference internal" href="#program">6. 定义构造program的函数</a></li>
<li class="toctree-l4"><a class="reference internal" href="#id7">7. 定义训练函数</a></li>
<li class="toctree-l4"><a class="reference internal" href="#id8">8. 定义预测函数</a></li>
<li class="toctree-l4"><a class="reference internal" href="#id9">9. 启动搜索实验</a></li>
<li class="toctree-l4"><a class="reference internal" href="#demo">10. 利用demo下的脚本启动搜索</a></li>
<li class="toctree-l4"><a class="reference internal" href="#id17">11. 利用demo下的脚本启动最终实验</a></li>
</ul>
</li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="paddledetection_slim_distillation_tutorial.html">目标检测模型蒸馏教程</a></li>
<li class="toctree-l2"><a class="reference internal" href="paddledetection_slim_nas_tutorial.html">人脸检测模型小模型结构搜索教程</a></li>
<li class="toctree-l2"><a class="reference internal" href="paddledetection_slim_pruing_tutorial.html">目标检测模型卷积通道剪裁教程</a></li>
<li class="toctree-l2"><a class="reference internal" href="paddledetection_slim_prune_dist_tutorial.html">目标检测模型蒸馏剪裁教程</a></li>
<li class="toctree-l2"><a class="reference internal" href="paddledetection_slim_quantization_tutorial.html">目标检测模型定点量化教程</a></li>
<li class="toctree-l2"><a class="reference internal" href="paddledetection_slim_sensitivy_tutorial.html">目标检测模型敏感度分析教程</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../api_cn/index.html">API文档</a></li>
<li class="toctree-l1"><a class="reference internal" href="../model_zoo.html">模型库</a></li>
<li class="toctree-l1"><a class="reference internal" href="../algo/algo.html">算法原理</a></li>
</ul>
</div>
</div>
</nav>
<section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">
<nav class="wy-nav-top" role="navigation" aria-label="top navigation">
<i data-toggle="wy-nav-top" class="fa fa-bars"></i>
<a href="../index.html">PaddleSlim</a>
</nav>
<div class="wy-nav-content">
<div class="rst-content">
<div role="navigation" aria-label="breadcrumbs navigation">
<ul class="wy-breadcrumbs">
<li><a href="../index.html">Docs</a> &raquo;</li>
<li><a href="index.html">进阶教程</a> &raquo;</li>
<li>SANAS进阶版实验教程-压缩DARTS产出模型</li>
<li class="wy-breadcrumbs-aside">
<a href="../_sources/tutorials/darts_nas_turorial.md.txt" rel="nofollow"> View page source</a>
</li>
</ul>
<hr/>
</div>
<div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
<div itemprop="articleBody">
<div class="section" id="sanas-darts">
<h1>SANAS进阶版实验教程-压缩DARTS产出模型<a class="headerlink" href="#sanas-darts" title="永久链接至标题"></a></h1>
<div class="section" id="id1">
<h2>收益情况<a class="headerlink" href="#id1" title="永久链接至标题"></a></h2>
<p>利用DARTS搜索出来的最终模型结构(以下简称为DARTS_model)构造相应的搜索空间,根据PaddleSlim提供的SANAS搜索方法进行搜索实验,最终得到的模型结构(以下简称为DARTS_SA)相比DARTS_model的精度提升<span class="raw-html-m2r"><font color=green>0.141%</font></span>,模型大小下降<span class="raw-html-m2r"><font color=green>11.2%</font></span></p>
</div>
<div class="section" id="id2">
<h2>搜索教程<a class="headerlink" href="#id2" title="永久链接至标题"></a></h2>
<p>本教程展示了如何在DARTS_model基础上利用SANAS进行搜索实验,并得到DARTS_SA的结果。</p>
<p>本教程包含以下步骤:</p>
<ol class="arabic simple">
<li>构造搜索空间</li>
<li>导入依赖包并定义全局变量</li>
<li>初始化SANAS实例</li>
<li>定义计算模型参数量的函数</li>
<li>定义网络输入数据的函数</li>
<li>定义造program的函数</li>
<li>定义训练函数</li>
<li>定义预测函数</li>
<li>启动搜索
9.1 获取下一个模型结构
9.2 构造相应的训练和预测program
9.3 添加搜索限制
9.4 定义环境
9.5 定义输入数据
9.6 启动训练和评估
9.7 回传当前模型的得分reward</li>
<li>利用demo下的脚本启动搜索</li>
<li>利用demo下的脚本启动最终实验</li>
</ol>
<div class="section" id="id3">
<h3>1. 构造搜索空间<a class="headerlink" href="#id3" title="永久链接至标题"></a></h3>
<p>进行搜索实验之前,首先需要根据DARTS_model的模型特点构造相应的搜索空间,本次实验仅会对DARTS_model的通道数进行搜索,搜索的目的是得到一个精度更高并且模型参数更少的模型。
定义如下搜索空间:</p>
<ul class="simple">
<li>通道数<code class="docutils literal"><span class="pre">filter_num</span></code>: 定义了每个卷积操作的通道数变化区间。取值区间为:<code class="docutils literal"><span class="pre">[4,</span> <span class="pre">8,</span> <span class="pre">12,</span> <span class="pre">16,</span> <span class="pre">20,</span> <span class="pre">36,</span> <span class="pre">54,</span> <span class="pre">72,</span> <span class="pre">90,</span> <span class="pre">108,</span> <span class="pre">144,</span> <span class="pre">180,</span> <span class="pre">216,</span> <span class="pre">252]</span></code></li>
</ul>
<p>按照通道数来区分DARTS_model中block的话,则DARTS_model中共有3个block,第一个block仅包含6个normal cell,之后的两个block每个block都包含和一个reduction cell和6个normal cell,共有20个cell。在构造搜索空间的时候我们定义每个cell中的所有卷积操作都使用相同的通道数,共有20位token。</p>
<p>完整的搜索空间可以参考<a class="reference external" href="../../../paddleslim/nas/search_space/darts_space.py">基于DARTS_model的搜索空间</a></p>
</div>
<div class="section" id="id4">
<h3>2. 引入依赖包并定义全局变量<a class="headerlink" href="#id4" title="永久链接至标题"></a></h3>
<div class="highlight-python"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">numpy</span> <span class="k">as</span> <span class="nn">np</span>
<span class="kn">import</span> <span class="nn">paddle</span>
<span class="kn">import</span> <span class="nn">paddle.fluid</span> <span class="k">as</span> <span class="nn">fluid</span>
<span class="kn">from</span> <span class="nn">paddleslim.nas</span> <span class="kn">import</span> <span class="n">SANAS</span>
<span class="n">BATCH_SIZE</span><span class="o">=</span><span class="mi">96</span>
<span class="n">SERVER_ADDRESS</span> <span class="o">=</span> <span class="s2">&quot;&quot;</span>
<span class="n">PORT</span> <span class="o">=</span> <span class="mi">8377</span>
<span class="n">SEARCH_STEPS</span> <span class="o">=</span> <span class="mi">300</span>
<span class="n">RETAIN_EPOCH</span><span class="o">=</span><span class="mi">30</span>
<span class="n">MAX_PARAMS</span><span class="o">=</span><span class="mf">3.77</span>
<span class="n">IMAGE_SHAPE</span><span class="o">=</span><span class="p">[</span><span class="mi">3</span><span class="p">,</span> <span class="mi">32</span><span class="p">,</span> <span class="mi">32</span><span class="p">]</span>
<span class="n">AUXILIARY</span> <span class="o">=</span> <span class="kc">True</span>
<span class="n">AUXILIARY_WEIGHT</span><span class="o">=</span> <span class="mf">0.4</span>
<span class="n">TRAINSET_NUM</span> <span class="o">=</span> <span class="mi">50000</span>
<span class="n">LR</span> <span class="o">=</span> <span class="mf">0.025</span>
<span class="n">MOMENTUM</span> <span class="o">=</span> <span class="mf">0.9</span>
<span class="n">WEIGHT_DECAY</span> <span class="o">=</span> <span class="mf">0.0003</span>
<span class="n">DROP_PATH_PROBILITY</span> <span class="o">=</span> <span class="mf">0.2</span>
</pre></div>
</div>
</div>
<div class="section" id="sanas">
<h3>3. 初始化SANAS实例<a class="headerlink" href="#sanas" title="永久链接至标题"></a></h3>
<p>首先需要初始化SANAS示例。</p>
<div class="highlight-python"><div class="highlight"><pre><span></span><span class="n">config</span> <span class="o">=</span> <span class="p">[(</span><span class="s1">&#39;DartsSpace&#39;</span><span class="p">)]</span>
<span class="n">sa_nas</span> <span class="o">=</span> <span class="n">SANAS</span><span class="p">(</span><span class="n">config</span><span class="p">,</span> <span class="n">server_addr</span><span class="o">=</span><span class="p">(</span><span class="n">SERVER_ADDRESS</span><span class="p">,</span> <span class="n">PORT</span><span class="p">),</span> <span class="n">search_steps</span><span class="o">=</span><span class="n">SEARCH_STEPS</span><span class="p">,</span> <span class="n">is_server</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span>
</pre></div>
</div>
</div>
<div class="section" id="id5">
<h3>4. 定义计算模型参数量的函数<a class="headerlink" href="#id5" title="永久链接至标题"></a></h3>
<p>根据输入的program计算当前模型中的参数量。本教程使用模型参数量作为搜索的限制条件。</p>
<div class="highlight-python"><div class="highlight"><pre><span></span><span class="k">def</span> <span class="nf">count_parameters_in_MB</span><span class="p">(</span><span class="n">all_params</span><span class="p">,</span> <span class="n">prefix</span><span class="o">=</span><span class="s1">&#39;model&#39;</span><span class="p">):</span>
<span class="n">parameters_number</span> <span class="o">=</span> <span class="mi">0</span>
<span class="k">for</span> <span class="n">param</span> <span class="ow">in</span> <span class="n">all_params</span><span class="p">:</span>
<span class="k">if</span> <span class="n">param</span><span class="o">.</span><span class="n">name</span><span class="o">.</span><span class="n">startswith</span><span class="p">(</span>
<span class="n">prefix</span><span class="p">)</span> <span class="ow">and</span> <span class="n">param</span><span class="o">.</span><span class="n">trainable</span> <span class="ow">and</span> <span class="s1">&#39;aux&#39;</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">param</span><span class="o">.</span><span class="n">name</span><span class="p">:</span>
<span class="n">parameters_number</span> <span class="o">+=</span> <span class="n">np</span><span class="o">.</span><span class="n">prod</span><span class="p">(</span><span class="n">param</span><span class="o">.</span><span class="n">shape</span><span class="p">)</span>
<span class="k">return</span> <span class="n">parameters_number</span> <span class="o">/</span> <span class="mf">1e6</span>
</pre></div>
</div>
</div>
<div class="section" id="id6">
<h3>5. 定义网络输入数据的函数<a class="headerlink" href="#id6" title="永久链接至标题"></a></h3>
<p>根据输入图片的尺寸定义网络中的输入,其中包括图片输入、标签输入和在训练过程中需要随机丢弃单元的比例和掩膜。</p>
<div class="highlight-python"><div class="highlight"><pre><span></span><span class="k">def</span> <span class="nf">create_data_loader</span><span class="p">(</span><span class="n">IMAGE_SHAPE</span><span class="p">,</span> <span class="n">is_train</span><span class="p">):</span>
<span class="n">image</span> <span class="o">=</span> <span class="n">fluid</span><span class="o">.</span><span class="n">data</span><span class="p">(</span>
<span class="n">name</span><span class="o">=</span><span class="s2">&quot;image&quot;</span><span class="p">,</span> <span class="n">shape</span><span class="o">=</span><span class="p">[</span><span class="kc">None</span><span class="p">]</span> <span class="o">+</span> <span class="n">IMAGE_SHAPE</span><span class="p">,</span> <span class="n">dtype</span><span class="o">=</span><span class="s2">&quot;float32&quot;</span><span class="p">)</span>
<span class="n">label</span> <span class="o">=</span> <span class="n">fluid</span><span class="o">.</span><span class="n">data</span><span class="p">(</span><span class="n">name</span><span class="o">=</span><span class="s2">&quot;label&quot;</span><span class="p">,</span> <span class="n">shape</span><span class="o">=</span><span class="p">[</span><span class="kc">None</span><span class="p">,</span> <span class="mi">1</span><span class="p">],</span> <span class="n">dtype</span><span class="o">=</span><span class="s2">&quot;int64&quot;</span><span class="p">)</span>
<span class="n">data_loader</span> <span class="o">=</span> <span class="n">fluid</span><span class="o">.</span><span class="n">io</span><span class="o">.</span><span class="n">DataLoader</span><span class="o">.</span><span class="n">from_generator</span><span class="p">(</span>
<span class="n">feed_list</span><span class="o">=</span><span class="p">[</span><span class="n">image</span><span class="p">,</span> <span class="n">label</span><span class="p">],</span>
<span class="n">capacity</span><span class="o">=</span><span class="mi">64</span><span class="p">,</span>
<span class="n">use_double_buffer</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span>
<span class="n">iterable</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span>
<span class="n">drop_path_prob</span> <span class="o">=</span> <span class="s1">&#39;&#39;</span>
<span class="n">drop_path_mask</span> <span class="o">=</span> <span class="s1">&#39;&#39;</span>
<span class="k">if</span> <span class="n">is_train</span><span class="p">:</span>
<span class="n">drop_path_prob</span> <span class="o">=</span> <span class="n">fluid</span><span class="o">.</span><span class="n">data</span><span class="p">(</span>
<span class="n">name</span><span class="o">=</span><span class="s2">&quot;drop_path_prob&quot;</span><span class="p">,</span> <span class="n">shape</span><span class="o">=</span><span class="p">[</span><span class="n">BATCH_SIZE</span><span class="p">,</span> <span class="mi">1</span><span class="p">],</span> <span class="n">dtype</span><span class="o">=</span><span class="s2">&quot;float32&quot;</span><span class="p">)</span>
<span class="n">drop_path_mask</span> <span class="o">=</span> <span class="n">fluid</span><span class="o">.</span><span class="n">data</span><span class="p">(</span>
<span class="n">name</span><span class="o">=</span><span class="s2">&quot;drop_path_mask&quot;</span><span class="p">,</span>
<span class="n">shape</span><span class="o">=</span><span class="p">[</span><span class="n">BATCH_SIZE</span><span class="p">,</span> <span class="mi">20</span><span class="p">,</span> <span class="mi">4</span><span class="p">,</span> <span class="mi">2</span><span class="p">],</span>
<span class="n">dtype</span><span class="o">=</span><span class="s2">&quot;float32&quot;</span><span class="p">)</span>
<span class="k">return</span> <span class="n">data_loader</span><span class="p">,</span> <span class="n">image</span><span class="p">,</span> <span class="n">label</span><span class="p">,</span> <span class="n">drop_path_prob</span><span class="p">,</span> <span class="n">drop_path_mask</span>
</pre></div>
</div>
</div>
<div class="section" id="program">
<h3>6. 定义构造program的函数<a class="headerlink" href="#program" title="永久链接至标题"></a></h3>
<p>根据输入的模型结构、输入图片尺寸和当前program是否是训练模式构造program。</p>
<div class="highlight-python"><div class="highlight"><pre><span></span><span class="k">def</span> <span class="nf">build_program</span><span class="p">(</span><span class="n">main_program</span><span class="p">,</span> <span class="n">startup_program</span><span class="p">,</span> <span class="n">IMAGE_SHAPE</span><span class="p">,</span> <span class="n">archs</span><span class="p">,</span> <span class="n">is_train</span><span class="p">):</span>
<span class="k">with</span> <span class="n">fluid</span><span class="o">.</span><span class="n">program_guard</span><span class="p">(</span><span class="n">main_program</span><span class="p">,</span> <span class="n">startup_program</span><span class="p">):</span>
<span class="n">data_loader</span><span class="p">,</span> <span class="n">data</span><span class="p">,</span> <span class="n">label</span><span class="p">,</span> <span class="n">drop_path_prob</span><span class="p">,</span> <span class="n">drop_path_mask</span> <span class="o">=</span> <span class="n">create_data_loader</span><span class="p">(</span>
<span class="n">IMAGE_SHAPE</span><span class="p">,</span> <span class="n">is_train</span><span class="p">)</span>
<span class="n">logits</span><span class="p">,</span> <span class="n">logits_aux</span> <span class="o">=</span> <span class="n">archs</span><span class="p">(</span><span class="n">data</span><span class="p">,</span> <span class="n">drop_path_prob</span><span class="p">,</span> <span class="n">drop_path_mask</span><span class="p">,</span>
<span class="n">is_train</span><span class="p">,</span> <span class="mi">10</span><span class="p">)</span>
<span class="n">top1</span> <span class="o">=</span> <span class="n">fluid</span><span class="o">.</span><span class="n">layers</span><span class="o">.</span><span class="n">accuracy</span><span class="p">(</span><span class="nb">input</span><span class="o">=</span><span class="n">logits</span><span class="p">,</span> <span class="n">label</span><span class="o">=</span><span class="n">label</span><span class="p">,</span> <span class="n">k</span><span class="o">=</span><span class="mi">1</span><span class="p">)</span>
<span class="n">top5</span> <span class="o">=</span> <span class="n">fluid</span><span class="o">.</span><span class="n">layers</span><span class="o">.</span><span class="n">accuracy</span><span class="p">(</span><span class="nb">input</span><span class="o">=</span><span class="n">logits</span><span class="p">,</span> <span class="n">label</span><span class="o">=</span><span class="n">label</span><span class="p">,</span> <span class="n">k</span><span class="o">=</span><span class="mi">5</span><span class="p">)</span>
<span class="n">loss</span> <span class="o">=</span> <span class="n">fluid</span><span class="o">.</span><span class="n">layers</span><span class="o">.</span><span class="n">reduce_mean</span><span class="p">(</span>
<span class="n">fluid</span><span class="o">.</span><span class="n">layers</span><span class="o">.</span><span class="n">softmax_with_cross_entropy</span><span class="p">(</span><span class="n">logits</span><span class="p">,</span> <span class="n">label</span><span class="p">))</span>
<span class="k">if</span> <span class="n">is_train</span><span class="p">:</span>
<span class="k">if</span> <span class="n">AUXILIARY</span><span class="p">:</span>
<span class="n">loss_aux</span> <span class="o">=</span> <span class="n">fluid</span><span class="o">.</span><span class="n">layers</span><span class="o">.</span><span class="n">reduce_mean</span><span class="p">(</span>
<span class="n">fluid</span><span class="o">.</span><span class="n">layers</span><span class="o">.</span><span class="n">softmax_with_cross_entropy</span><span class="p">(</span><span class="n">logits_aux</span><span class="p">,</span> <span class="n">label</span><span class="p">))</span>
<span class="n">loss</span> <span class="o">=</span> <span class="n">loss</span> <span class="o">+</span> <span class="n">AUXILIARY_WEIGHT</span> <span class="o">*</span> <span class="n">loss_aux</span>
<span class="n">step_per_epoch</span> <span class="o">=</span> <span class="nb">int</span><span class="p">(</span><span class="n">TRAINSET_NUM</span> <span class="o">/</span> <span class="n">BATCH_SIZE</span><span class="p">)</span>
<span class="n">learning_rate</span> <span class="o">=</span> <span class="n">fluid</span><span class="o">.</span><span class="n">layers</span><span class="o">.</span><span class="n">cosine_decay</span><span class="p">(</span><span class="n">LR</span><span class="p">,</span> <span class="n">step_per_epoch</span><span class="p">,</span> <span class="n">RETAIN_EPOCH</span><span class="p">)</span>
<span class="n">fluid</span><span class="o">.</span><span class="n">clip</span><span class="o">.</span><span class="n">set_gradient_clip</span><span class="p">(</span>
<span class="n">clip</span><span class="o">=</span><span class="n">fluid</span><span class="o">.</span><span class="n">clip</span><span class="o">.</span><span class="n">GradientClipByGlobalNorm</span><span class="p">(</span><span class="n">clip_norm</span><span class="o">=</span><span class="mf">5.0</span><span class="p">))</span>
<span class="n">optimizer</span> <span class="o">=</span> <span class="n">fluid</span><span class="o">.</span><span class="n">optimizer</span><span class="o">.</span><span class="n">MomentumOptimizer</span><span class="p">(</span>
<span class="n">learning_rate</span><span class="p">,</span>
<span class="n">MOMENTUM</span><span class="p">,</span>
<span class="n">regularization</span><span class="o">=</span><span class="n">fluid</span><span class="o">.</span><span class="n">regularizer</span><span class="o">.</span><span class="n">L2DecayRegularizer</span><span class="p">(</span>
<span class="n">WEIGHT_DECAY</span><span class="p">))</span>
<span class="n">optimizer</span><span class="o">.</span><span class="n">minimize</span><span class="p">(</span><span class="n">loss</span><span class="p">)</span>
<span class="n">outs</span> <span class="o">=</span> <span class="p">[</span><span class="n">loss</span><span class="p">,</span> <span class="n">top1</span><span class="p">,</span> <span class="n">top5</span><span class="p">,</span> <span class="n">learning_rate</span><span class="p">]</span>
<span class="k">else</span><span class="p">:</span>
<span class="n">outs</span> <span class="o">=</span> <span class="p">[</span><span class="n">loss</span><span class="p">,</span> <span class="n">top1</span><span class="p">,</span> <span class="n">top5</span><span class="p">]</span>
<span class="k">return</span> <span class="n">outs</span><span class="p">,</span> <span class="n">data_loader</span>
</pre></div>
</div>
</div>
<div class="section" id="id7">
<h3>7. 定义训练函数<a class="headerlink" href="#id7" title="永久链接至标题"></a></h3>
<div class="highlight-python"><div class="highlight"><pre><span></span><span class="k">def</span> <span class="nf">train</span><span class="p">(</span><span class="n">main_prog</span><span class="p">,</span> <span class="n">exe</span><span class="p">,</span> <span class="n">epoch_id</span><span class="p">,</span> <span class="n">train_loader</span><span class="p">,</span> <span class="n">fetch_list</span><span class="p">):</span>
<span class="n">loss</span> <span class="o">=</span> <span class="p">[]</span>
<span class="n">top1</span> <span class="o">=</span> <span class="p">[]</span>
<span class="n">top5</span> <span class="o">=</span> <span class="p">[]</span>
<span class="k">for</span> <span class="n">step_id</span><span class="p">,</span> <span class="n">data</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">train_loader</span><span class="p">()):</span>
<span class="n">devices_num</span> <span class="o">=</span> <span class="nb">len</span><span class="p">(</span><span class="n">data</span><span class="p">)</span>
<span class="k">if</span> <span class="n">DROP_PATH_PROBILITY</span> <span class="o">&gt;</span> <span class="mi">0</span><span class="p">:</span>
<span class="n">feed</span> <span class="o">=</span> <span class="p">[]</span>
<span class="k">for</span> <span class="n">device_id</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="n">devices_num</span><span class="p">):</span>
<span class="n">image</span> <span class="o">=</span> <span class="n">data</span><span class="p">[</span><span class="n">device_id</span><span class="p">][</span><span class="s1">&#39;image&#39;</span><span class="p">]</span>
<span class="n">label</span> <span class="o">=</span> <span class="n">data</span><span class="p">[</span><span class="n">device_id</span><span class="p">][</span><span class="s1">&#39;label&#39;</span><span class="p">]</span>
<span class="n">drop_path_prob</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">(</span>
<span class="p">[[</span><span class="n">DROP_PATH_PROBILITY</span> <span class="o">*</span> <span class="n">epoch_id</span> <span class="o">/</span> <span class="n">RETAIN_EPOCH</span><span class="p">]</span>
<span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="n">BATCH_SIZE</span><span class="p">)])</span><span class="o">.</span><span class="n">astype</span><span class="p">(</span><span class="n">np</span><span class="o">.</span><span class="n">float32</span><span class="p">)</span>
<span class="n">drop_path_mask</span> <span class="o">=</span> <span class="mi">1</span> <span class="o">-</span> <span class="n">np</span><span class="o">.</span><span class="n">random</span><span class="o">.</span><span class="n">binomial</span><span class="p">(</span>
<span class="mi">1</span><span class="p">,</span> <span class="n">drop_path_prob</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span>
<span class="n">size</span><span class="o">=</span><span class="p">[</span><span class="n">BATCH_SIZE</span><span class="p">,</span> <span class="mi">20</span><span class="p">,</span> <span class="mi">4</span><span class="p">,</span> <span class="mi">2</span><span class="p">])</span><span class="o">.</span><span class="n">astype</span><span class="p">(</span><span class="n">np</span><span class="o">.</span><span class="n">float32</span><span class="p">)</span>
<span class="n">feed</span><span class="o">.</span><span class="n">append</span><span class="p">({</span>
<span class="s2">&quot;image&quot;</span><span class="p">:</span> <span class="n">image</span><span class="p">,</span>
<span class="s2">&quot;label&quot;</span><span class="p">:</span> <span class="n">label</span><span class="p">,</span>
<span class="s2">&quot;drop_path_prob&quot;</span><span class="p">:</span> <span class="n">drop_path_prob</span><span class="p">,</span>
<span class="s2">&quot;drop_path_mask&quot;</span><span class="p">:</span> <span class="n">drop_path_mask</span>
<span class="p">})</span>
<span class="k">else</span><span class="p">:</span>
<span class="n">feed</span> <span class="o">=</span> <span class="n">data</span>
<span class="n">loss_v</span><span class="p">,</span> <span class="n">top1_v</span><span class="p">,</span> <span class="n">top5_v</span><span class="p">,</span> <span class="n">lr</span> <span class="o">=</span> <span class="n">exe</span><span class="o">.</span><span class="n">run</span><span class="p">(</span>
<span class="n">main_prog</span><span class="p">,</span> <span class="n">feed</span><span class="o">=</span><span class="n">feed</span><span class="p">,</span> <span class="n">fetch_list</span><span class="o">=</span><span class="p">[</span><span class="n">v</span><span class="o">.</span><span class="n">name</span> <span class="k">for</span> <span class="n">v</span> <span class="ow">in</span> <span class="n">fetch_list</span><span class="p">])</span>
<span class="n">loss</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">loss_v</span><span class="p">)</span>
<span class="n">top1</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">top1_v</span><span class="p">)</span>
<span class="n">top5</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">top5_v</span><span class="p">)</span>
<span class="k">if</span> <span class="n">step_id</span> <span class="o">%</span> <span class="mi">10</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span>
<span class="nb">print</span><span class="p">(</span>
<span class="s2">&quot;Train Epoch </span><span class="si">{}</span><span class="s2">, Step </span><span class="si">{}</span><span class="s2">, Lr </span><span class="si">{:.8f}</span><span class="s2">, loss </span><span class="si">{:.6f}</span><span class="s2">, acc_1 </span><span class="si">{:.6f}</span><span class="s2">, acc_5 </span><span class="si">{:.6f}</span><span class="s2">&quot;</span><span class="o">.</span>
<span class="nb">format</span><span class="p">(</span><span class="n">epoch_id</span><span class="p">,</span> <span class="n">step_id</span><span class="p">,</span> <span class="n">lr</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="n">np</span><span class="o">.</span><span class="n">mean</span><span class="p">(</span><span class="n">loss</span><span class="p">),</span> <span class="n">np</span><span class="o">.</span><span class="n">mean</span><span class="p">(</span><span class="n">top1</span><span class="p">),</span> <span class="n">np</span><span class="o">.</span><span class="n">mean</span><span class="p">(</span><span class="n">top5</span><span class="p">)))</span>
<span class="k">return</span> <span class="n">np</span><span class="o">.</span><span class="n">mean</span><span class="p">(</span><span class="n">top1</span><span class="p">)</span>
</pre></div>
</div>
</div>
<div class="section" id="id8">
<h3>8. 定义预测函数<a class="headerlink" href="#id8" title="永久链接至标题"></a></h3>
<div class="highlight-python"><div class="highlight"><pre><span></span><span class="k">def</span> <span class="nf">valid</span><span class="p">(</span><span class="n">main_prog</span><span class="p">,</span> <span class="n">exe</span><span class="p">,</span> <span class="n">epoch_id</span><span class="p">,</span> <span class="n">valid_loader</span><span class="p">,</span> <span class="n">fetch_list</span><span class="p">):</span>
<span class="n">loss</span> <span class="o">=</span> <span class="p">[]</span>
<span class="n">top1</span> <span class="o">=</span> <span class="p">[]</span>
<span class="n">top5</span> <span class="o">=</span> <span class="p">[]</span>
<span class="k">for</span> <span class="n">step_id</span><span class="p">,</span> <span class="n">data</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">valid_loader</span><span class="p">()):</span>
<span class="n">loss_v</span><span class="p">,</span> <span class="n">top1_v</span><span class="p">,</span> <span class="n">top5_v</span> <span class="o">=</span> <span class="n">exe</span><span class="o">.</span><span class="n">run</span><span class="p">(</span>
<span class="n">main_prog</span><span class="p">,</span> <span class="n">feed</span><span class="o">=</span><span class="n">data</span><span class="p">,</span> <span class="n">fetch_list</span><span class="o">=</span><span class="p">[</span><span class="n">v</span><span class="o">.</span><span class="n">name</span> <span class="k">for</span> <span class="n">v</span> <span class="ow">in</span> <span class="n">fetch_list</span><span class="p">])</span>
<span class="n">loss</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">loss_v</span><span class="p">)</span>
<span class="n">top1</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">top1_v</span><span class="p">)</span>
<span class="n">top5</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">top5_v</span><span class="p">)</span>
<span class="k">if</span> <span class="n">step_id</span> <span class="o">%</span> <span class="mi">10</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span>
<span class="nb">print</span><span class="p">(</span>
<span class="s2">&quot;Valid Epoch </span><span class="si">{}</span><span class="s2">, Step </span><span class="si">{}</span><span class="s2">, loss </span><span class="si">{:.6f}</span><span class="s2">, acc_1 </span><span class="si">{:.6f}</span><span class="s2">, acc_5 </span><span class="si">{:.6f}</span><span class="s2">&quot;</span><span class="o">.</span>
<span class="nb">format</span><span class="p">(</span><span class="n">epoch_id</span><span class="p">,</span> <span class="n">step_id</span><span class="p">,</span> <span class="n">np</span><span class="o">.</span><span class="n">mean</span><span class="p">(</span><span class="n">loss</span><span class="p">),</span> <span class="n">np</span><span class="o">.</span><span class="n">mean</span><span class="p">(</span><span class="n">top1</span><span class="p">),</span> <span class="n">np</span><span class="o">.</span><span class="n">mean</span><span class="p">(</span><span class="n">top5</span><span class="p">)))</span>
<span class="k">return</span> <span class="n">np</span><span class="o">.</span><span class="n">mean</span><span class="p">(</span><span class="n">top1</span><span class="p">)</span>
</pre></div>
</div>
</div>
<div class="section" id="id9">
<h3>9. 启动搜索实验<a class="headerlink" href="#id9" title="永久链接至标题"></a></h3>
<p>以下步骤拆解说明了如何获得当前模型结构以及获得当前模型结构之后应该有的步骤。</p>
<div class="section" id="id10">
<h4>9.1 获取下一个模型结构<a class="headerlink" href="#id10" title="永久链接至标题"></a></h4>
<p>根据上面的SANAS实例中的函数获取下一个模型结构。</p>
<div class="highlight-python"><div class="highlight"><pre><span></span><span class="n">archs</span> <span class="o">=</span> <span class="n">sa_nas</span><span class="o">.</span><span class="n">next_archs</span><span class="p">()[</span><span class="mi">0</span><span class="p">]</span>
</pre></div>
</div>
</div>
<div class="section" id="id11">
<h4>9.2 构造训练和预测program<a class="headerlink" href="#id11" title="永久链接至标题"></a></h4>
<p>根据上一步中获得的模型结构分别构造训练program和预测program。</p>
<div class="highlight-python"><div class="highlight"><pre><span></span><span class="n">train_program</span> <span class="o">=</span> <span class="n">fluid</span><span class="o">.</span><span class="n">Program</span><span class="p">()</span>
<span class="n">test_program</span> <span class="o">=</span> <span class="n">fluid</span><span class="o">.</span><span class="n">Program</span><span class="p">()</span>
<span class="n">startup_program</span> <span class="o">=</span> <span class="n">fluid</span><span class="o">.</span><span class="n">Program</span><span class="p">()</span>
<span class="n">train_fetch_list</span><span class="p">,</span> <span class="n">train_loader</span> <span class="o">=</span> <span class="n">build_program</span><span class="p">(</span><span class="n">train_program</span><span class="p">,</span> <span class="n">startup_program</span><span class="p">,</span> <span class="n">IMAGE_SHAPE</span><span class="p">,</span> <span class="n">archs</span><span class="p">,</span> <span class="n">is_train</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span>
<span class="n">test_fetch_list</span><span class="p">,</span> <span class="n">test_loader</span> <span class="o">=</span> <span class="n">build_program</span><span class="p">(</span><span class="n">test_program</span><span class="p">,</span> <span class="n">startup_program</span><span class="p">,</span> <span class="n">IMAGE_SHAPE</span><span class="p">,</span> <span class="n">archs</span><span class="p">,</span> <span class="n">is_train</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span>
<span class="n">test_program</span> <span class="o">=</span> <span class="n">test_program</span><span class="o">.</span><span class="n">clone</span><span class="p">(</span><span class="n">for_test</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span>
</pre></div>
</div>
</div>
<div class="section" id="id12">
<h4>9.3 添加搜索限制<a class="headerlink" href="#id12" title="永久链接至标题"></a></h4>
<p>本教程以模型参数量为限制条件。首先计算一下当前program的参数量,如果超出限制条件,则终止本次模型结构的训练,获取下一个模型结构。</p>
<div class="highlight-python"><div class="highlight"><pre><span></span><span class="n">current_params</span> <span class="o">=</span> <span class="n">count_parameters_in_MB</span><span class="p">(</span>
<span class="n">train_program</span><span class="o">.</span><span class="n">global_block</span><span class="p">()</span><span class="o">.</span><span class="n">all_parameters</span><span class="p">(),</span> <span class="s1">&#39;cifar10&#39;</span><span class="p">)</span>
</pre></div>
</div>
</div>
<div class="section" id="id13">
<h4>9.4 定义环境<a class="headerlink" href="#id13" title="永久链接至标题"></a></h4>
<p>定义数据和模型的环境并初始化参数。</p>
<div class="highlight-python"><div class="highlight"><pre><span></span><span class="n">place</span> <span class="o">=</span> <span class="n">fluid</span><span class="o">.</span><span class="n">CPUPlace</span><span class="p">()</span>
<span class="n">exe</span> <span class="o">=</span> <span class="n">fluid</span><span class="o">.</span><span class="n">Executor</span><span class="p">(</span><span class="n">place</span><span class="p">)</span>
<span class="n">exe</span><span class="o">.</span><span class="n">run</span><span class="p">(</span><span class="n">startup_program</span><span class="p">)</span>
</pre></div>
</div>
</div>
<div class="section" id="id14">
<h4>9.5 定义输入数据<a class="headerlink" href="#id14" title="永久链接至标题"></a></h4>
<p>由于本示例中对cifar10中的图片进行了一些额外的预处理操作,和<a class="reference external" href="../quick_start/nas_tutorial.md">快速开始</a>示例中的reader不同,所以需要自定义cifar10的reader,不能直接调用paddle中封装好的<code class="docutils literal"><span class="pre">paddle.dataset.cifar10</span></code>的reader。自定义cifar10的reader文件位于<a class="reference external" href="../../../demo/nas/darts_cifar10_reader.py">demo/nas</a>中。</p>
<p><strong>注意:</strong>本示例为了简化代码直接调用<code class="docutils literal"><span class="pre">paddle.dataset.cifar10</span></code>定义训练数据和预测数据,实际训练需要使用自定义cifar10的reader。</p>
<div class="highlight-python"><div class="highlight"><pre><span></span><span class="n">train_reader</span> <span class="o">=</span> <span class="n">paddle</span><span class="o">.</span><span class="n">batch</span><span class="p">(</span><span class="n">paddle</span><span class="o">.</span><span class="n">reader</span><span class="o">.</span><span class="n">shuffle</span><span class="p">(</span><span class="n">paddle</span><span class="o">.</span><span class="n">dataset</span><span class="o">.</span><span class="n">cifar</span><span class="o">.</span><span class="n">train10</span><span class="p">(</span><span class="n">cycle</span><span class="o">=</span><span class="kc">False</span><span class="p">),</span> <span class="n">buf_size</span><span class="o">=</span><span class="mi">1024</span><span class="p">),</span> <span class="n">batch_size</span><span class="o">=</span><span class="n">BATCH_SIZE</span><span class="p">,</span> <span class="n">drop_last</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span>
<span class="n">test_reader</span> <span class="o">=</span> <span class="n">paddle</span><span class="o">.</span><span class="n">batch</span><span class="p">(</span><span class="n">paddle</span><span class="o">.</span><span class="n">dataset</span><span class="o">.</span><span class="n">cifar</span><span class="o">.</span><span class="n">test10</span><span class="p">(</span><span class="n">cycle</span><span class="o">=</span><span class="kc">False</span><span class="p">),</span> <span class="n">batch_size</span><span class="o">=</span><span class="n">BATCH_SIZE</span><span class="p">,</span> <span class="n">drop_last</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span>
<span class="n">train_loader</span><span class="o">.</span><span class="n">set_sample_list_generator</span><span class="p">(</span><span class="n">train_reader</span><span class="p">,</span> <span class="n">places</span><span class="o">=</span><span class="n">place</span><span class="p">)</span>
<span class="n">test_loader</span><span class="o">.</span><span class="n">set_sample_list_generator</span><span class="p">(</span><span class="n">test_reader</span><span class="p">,</span> <span class="n">places</span><span class="o">=</span><span class="n">place</span><span class="p">)</span>
</pre></div>
</div>
</div>
<div class="section" id="id16">
<h4>9.6 启动训练和评估<a class="headerlink" href="#id16" title="永久链接至标题"></a></h4>
<div class="highlight-python"><div class="highlight"><pre><span></span><span class="k">for</span> <span class="n">epoch_id</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="n">RETAIN_EPOCH</span><span class="p">):</span>
<span class="n">train_top1</span> <span class="o">=</span> <span class="n">train</span><span class="p">(</span><span class="n">train_program</span><span class="p">,</span> <span class="n">exe</span><span class="p">,</span> <span class="n">epoch_id</span><span class="p">,</span> <span class="n">train_loader</span><span class="p">,</span> <span class="n">train_fetch_list</span><span class="p">)</span>
<span class="nb">print</span><span class="p">(</span><span class="s2">&quot;TRAIN: Epoch </span><span class="si">{}</span><span class="s2">, train_acc </span><span class="si">{:.6f}</span><span class="s2">&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">epoch_id</span><span class="p">,</span> <span class="n">train_top1</span><span class="p">))</span>
<span class="n">valid_top1</span> <span class="o">=</span> <span class="n">valid</span><span class="p">(</span><span class="n">test_program</span><span class="p">,</span> <span class="n">exe</span><span class="p">,</span> <span class="n">epoch_id</span><span class="p">,</span> <span class="n">test_loader</span><span class="p">,</span> <span class="n">test_fetch_list</span><span class="p">)</span>
<span class="nb">print</span><span class="p">(</span><span class="s2">&quot;TEST: Epoch </span><span class="si">{}</span><span class="s2">, valid_acc </span><span class="si">{:.6f}</span><span class="s2">&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">epoch_id</span><span class="p">,</span> <span class="n">valid_top1</span><span class="p">))</span>
<span class="n">valid_top1_list</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">valid_top1</span><span class="p">)</span>
</pre></div>
</div>
</div>
<div class="section" id="reward">
<h4>9.7 回传当前模型的得分reward<a class="headerlink" href="#reward" title="永久链接至标题"></a></h4>
<p>本教程利用最后两个epoch的准确率均值作为最终的得分回传给SANAS。</p>
<div class="highlight-python"><div class="highlight"><pre><span></span><span class="n">sa_nas</span><span class="o">.</span><span class="n">reward</span><span class="p">(</span><span class="nb">float</span><span class="p">(</span><span class="n">valid_top1_list</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span> <span class="o">+</span> <span class="n">valid_top1_list</span><span class="p">[</span><span class="o">-</span><span class="mi">2</span><span class="p">])</span> <span class="o">/</span> <span class="mi">2</span><span class="p">)</span>
</pre></div>
</div>
</div>
</div>
<div class="section" id="demo">
<h3>10. 利用demo下的脚本启动搜索<a class="headerlink" href="#demo" title="永久链接至标题"></a></h3>
<p>搜索文件位于: <a class="reference external" href="https://github.com/PaddlePaddle/PaddleSlim/tree/develop/demo/nas/darts_nas.py">darts_sanas_demo</a>,搜索过程中限制模型参数量为不大于3.77M。</p>
<div class="highlight-python"><div class="highlight"><pre><span></span><span class="n">cd</span> <span class="n">demo</span><span class="o">/</span><span class="n">nas</span><span class="o">/</span>
<span class="n">python</span> <span class="n">darts_nas</span><span class="o">.</span><span class="n">py</span>
</pre></div>
</div>
</div>
<div class="section" id="id17">
<h3>11. 利用demo下的脚本启动最终实验<a class="headerlink" href="#id17" title="永久链接至标题"></a></h3>
<p>最终实验文件位于: <a class="reference external" href="https://github.com/PaddlePaddle/PaddleSlim/tree/develop/demo/nas/darts_nas.py">darts_sanas_demo</a>,最终实验需要训练600epoch。以下示例输入token为<code class="docutils literal"><span class="pre">[5,</span> <span class="pre">5,</span> <span class="pre">0,</span> <span class="pre">5,</span> <span class="pre">5,</span> <span class="pre">10,</span> <span class="pre">7,</span> <span class="pre">7,</span> <span class="pre">5,</span> <span class="pre">7,</span> <span class="pre">7,</span> <span class="pre">11,</span> <span class="pre">10,</span> <span class="pre">12,</span> <span class="pre">10,</span> <span class="pre">0,</span> <span class="pre">5,</span> <span class="pre">3,</span> <span class="pre">10,</span> <span class="pre">8]</span></code></p>
<div class="highlight-python"><div class="highlight"><pre><span></span><span class="n">cd</span> <span class="n">demo</span><span class="o">/</span><span class="n">nas</span><span class="o">/</span>
<span class="n">python</span> <span class="n">darts_nas</span><span class="o">.</span><span class="n">py</span> <span class="o">--</span><span class="n">token</span> <span class="mi">5</span> <span class="mi">5</span> <span class="mi">0</span> <span class="mi">5</span> <span class="mi">5</span> <span class="mi">10</span> <span class="mi">7</span> <span class="mi">7</span> <span class="mi">5</span> <span class="mi">7</span> <span class="mi">7</span> <span class="mi">11</span> <span class="mi">10</span> <span class="mi">12</span> <span class="mi">10</span> <span class="mi">0</span> <span class="mi">5</span> <span class="mi">3</span> <span class="mi">10</span> <span class="mi">8</span> <span class="o">--</span><span class="n">retain_epoch</span> <span class="mi">600</span>
</pre></div>
</div>
</div>
</div>
</div>
</div>
</div>
<footer>
<div class="rst-footer-buttons" role="navigation" aria-label="footer navigation">
<a href="paddledetection_slim_distillation_tutorial.html" class="btn btn-neutral float-right" title="目标检测模型蒸馏教程" accesskey="n">Next <span class="fa fa-arrow-circle-right"></span></a>
<a href="image_classification_sensitivity_analysis_tutorial.html" class="btn btn-neutral" title="图像分类模型通道剪裁-敏感度分析" accesskey="p"><span class="fa fa-arrow-circle-left"></span> Previous</a>
</div>
<hr/>
<div role="contentinfo">
<p>
&copy; Copyright 2020, paddleslim.
</p>
</div>
Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/snide/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>.
</footer>
</div>
</div>
</section>
</div>
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT:'../',
VERSION:'1.0',
COLLAPSE_INDEX:false,
FILE_SUFFIX:'.html',
HAS_SOURCE: true
};
</script>
<script type="text/javascript" src="../_static/jquery.js"></script>
<script type="text/javascript" src="../_static/underscore.js"></script>
<script type="text/javascript" src="../_static/doctools.js"></script>
<script type="text/javascript" src="../_static/translations.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
<script type="text/javascript" src="../_static/js/theme.js"></script>
<script type="text/javascript">
jQuery(function () {
SphinxRtdTheme.StickyNav.enable();
});
</script>
</body>
</html>
\ No newline at end of file
...@@ -35,7 +35,7 @@ ...@@ -35,7 +35,7 @@
<link rel="search" title="搜索" href="../search.html"/> <link rel="search" title="搜索" href="../search.html"/>
<link rel="top" title="PaddleSlim 1.0 文档" href="../index.html"/> <link rel="top" title="PaddleSlim 1.0 文档" href="../index.html"/>
<link rel="up" title="进阶教程" href="index.html"/> <link rel="up" title="进阶教程" href="index.html"/>
<link rel="next" title="API文档" href="../api_cn/index.html"/> <link rel="next" title="SANAS进阶版实验教程-压缩DARTS产出模型" href="darts_nas_turorial.html"/>
<link rel="prev" title="进阶教程" href="index.html"/> <link rel="prev" title="进阶教程" href="index.html"/>
...@@ -83,7 +83,7 @@ ...@@ -83,7 +83,7 @@
<ul class="current"> <ul class="current">
<li class="toctree-l1"><a class="reference internal" href="../index_en.html">English Documents</a></li> <li class="toctree-l1"><a class="reference internal" href="../index_en.html">English Documents</a></li>
<li class="toctree-l1"><a class="reference internal" href="../intro.html">PaddleSlim简介</a></li> <li class="toctree-l1"><a class="reference internal" href="../intro.html">介绍</a></li>
<li class="toctree-l1"><a class="reference internal" href="../install.html">安装</a></li> <li class="toctree-l1"><a class="reference internal" href="../install.html">安装</a></li>
<li class="toctree-l1"><a class="reference internal" href="../quick_start/index.html">快速开始</a></li> <li class="toctree-l1"><a class="reference internal" href="../quick_start/index.html">快速开始</a></li>
<li class="toctree-l1 current"><a class="reference internal" href="index.html">进阶教程</a><ul class="current"> <li class="toctree-l1 current"><a class="reference internal" href="index.html">进阶教程</a><ul class="current">
...@@ -109,6 +109,13 @@ ...@@ -109,6 +109,13 @@
</li> </li>
</ul> </ul>
</li> </li>
<li class="toctree-l2"><a class="reference internal" href="darts_nas_turorial.html">SANAS进阶版实验教程-压缩DARTS产出模型</a></li>
<li class="toctree-l2"><a class="reference internal" href="paddledetection_slim_distillation_tutorial.html">目标检测模型蒸馏教程</a></li>
<li class="toctree-l2"><a class="reference internal" href="paddledetection_slim_nas_tutorial.html">人脸检测模型小模型结构搜索教程</a></li>
<li class="toctree-l2"><a class="reference internal" href="paddledetection_slim_pruing_tutorial.html">目标检测模型卷积通道剪裁教程</a></li>
<li class="toctree-l2"><a class="reference internal" href="paddledetection_slim_prune_dist_tutorial.html">目标检测模型蒸馏剪裁教程</a></li>
<li class="toctree-l2"><a class="reference internal" href="paddledetection_slim_quantization_tutorial.html">目标检测模型定点量化教程</a></li>
<li class="toctree-l2"><a class="reference internal" href="paddledetection_slim_sensitivy_tutorial.html">目标检测模型敏感度分析教程</a></li>
</ul> </ul>
</li> </li>
<li class="toctree-l1"><a class="reference internal" href="../api_cn/index.html">API文档</a></li> <li class="toctree-l1"><a class="reference internal" href="../api_cn/index.html">API文档</a></li>
...@@ -164,7 +171,7 @@ ...@@ -164,7 +171,7 @@
<h1>图像分类模型通道剪裁-敏感度分析<a class="headerlink" href="#id1" title="永久链接至标题"></a></h1> <h1>图像分类模型通道剪裁-敏感度分析<a class="headerlink" href="#id1" title="永久链接至标题"></a></h1>
<p>该教程以图像分类模型MobileNetV1为例,说明如何快速使用<a class="reference external" href="https://paddlepaddle.github.io/PaddleSlim/api/prune_api/#sensitivity">PaddleSlim的敏感度分析接口</a> <p>该教程以图像分类模型MobileNetV1为例,说明如何快速使用<a class="reference external" href="https://paddlepaddle.github.io/PaddleSlim/api/prune_api/#sensitivity">PaddleSlim的敏感度分析接口</a>
该示例包含以下步骤:</p> 该示例包含以下步骤:</p>
<ol class="simple"> <ol class="arabic simple">
<li>导入依赖</li> <li>导入依赖</li>
<li>构建模型</li> <li>构建模型</li>
<li>定义输入数据</li> <li>定义输入数据</li>
...@@ -398,7 +405,7 @@ ...@@ -398,7 +405,7 @@
<div class="rst-footer-buttons" role="navigation" aria-label="footer navigation"> <div class="rst-footer-buttons" role="navigation" aria-label="footer navigation">
<a href="../api_cn/index.html" class="btn btn-neutral float-right" title="API文档" accesskey="n">Next <span class="fa fa-arrow-circle-right"></span></a> <a href="darts_nas_turorial.html" class="btn btn-neutral float-right" title="SANAS进阶版实验教程-压缩DARTS产出模型" accesskey="n">Next <span class="fa fa-arrow-circle-right"></span></a>
<a href="index.html" class="btn btn-neutral" title="进阶教程" accesskey="p"><span class="fa fa-arrow-circle-left"></span> Previous</a> <a href="index.html" class="btn btn-neutral" title="进阶教程" accesskey="p"><span class="fa fa-arrow-circle-left"></span> Previous</a>
......
<!DOCTYPE html>
<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]-->
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Pruning of image classification model - sensitivity &mdash; PaddleSlim 1.0 documentation</title>
<link rel="stylesheet" href="../_static/css/theme.css" type="text/css" />
<link rel="index" title="Index"
href="../genindex.html"/>
<link rel="search" title="Search" href="../search.html"/>
<link rel="top" title="PaddleSlim 1.0 documentation" href="../index.html"/>
<link rel="up" title="Aadvanced Tutorials" href="index_en.html"/>
<link rel="next" title="API Documents" href="../api_en/index_en.html"/>
<link rel="prev" title="Aadvanced Tutorials" href="index_en.html"/>
<script src="../_static/js/modernizr.min.js"></script>
</head>
<body class="wy-body-for-nav" role="document">
<div class="wy-grid-for-nav">
<nav data-toggle="wy-nav-shift" class="wy-nav-side">
<div class="wy-side-scroll">
<div class="wy-side-nav-search">
<a href="../index_en.html" class="icon icon-home"> PaddleSlim
</a>
<div role="search">
<form id="rtd-search-form" class="wy-form" action="../search.html" method="get">
<input type="text" name="q" placeholder="Search docs" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
</div>
</div>
<div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
<ul class="current">
<li class="toctree-l1"><a class="reference internal" href="../index.html">中文文档</a></li>
<li class="toctree-l1"><a class="reference internal" href="../intro_en.html">Introduction</a></li>
<li class="toctree-l1"><a class="reference internal" href="../install_en.html">Install</a></li>
<li class="toctree-l1"><a class="reference internal" href="../quick_start/index_en.html">Quick Start</a></li>
<li class="toctree-l1 current"><a class="reference internal" href="index_en.html">Aadvanced Tutorials</a><ul class="current">
<li class="toctree-l2 current"><a class="current reference internal" href="#">Pruning of image classification model - sensitivity</a><ul>
<li class="toctree-l3"><a class="reference internal" href="#import-dependency">1. Import dependency</a></li>
<li class="toctree-l3"><a class="reference internal" href="#build-model">2. Build model</a></li>
<li class="toctree-l3"><a class="reference internal" href="#define-data-reader">3 Define data reader</a></li>
<li class="toctree-l3"><a class="reference internal" href="#define-test-function">4. Define test function</a></li>
<li class="toctree-l3"><a class="reference internal" href="#training-model">5. Training model</a></li>
<li class="toctree-l3"><a class="reference internal" href="#get-names-of-parameters">6. Get names of parameters</a></li>
<li class="toctree-l3"><a class="reference internal" href="#compute-sensitivities">7. Compute sensitivities</a><ul>
<li class="toctree-l4"><a class="reference internal" href="#compute-in-single-process">7.1 Compute in single process</a></li>
<li class="toctree-l4"><a class="reference internal" href="#expand-sensitivities">7.2 Expand sensitivities</a></li>
<li class="toctree-l4"><a class="reference internal" href="#computing-sensitivity-in-multi-process">7.3 Computing sensitivity in multi-process</a></li>
</ul>
</li>
<li class="toctree-l3"><a class="reference internal" href="#pruning-model">8. Pruning model</a><ul>
<li class="toctree-l4"><a class="reference internal" href="#get-pruning-ratios">8.1 Get pruning ratios</a></li>
<li class="toctree-l4"><a class="reference internal" href="#pruning-training-network">8.2 Pruning training network</a></li>
<li class="toctree-l4"><a class="reference internal" href="#pruning-test-network">8.3 Pruning test network</a></li>
<li class="toctree-l4"><a class="reference internal" href="#training-pruned-model">8.4 Training pruned model</a></li>
</ul>
</li>
</ul>
</li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../api_en/index_en.html">API Documents</a></li>
<li class="toctree-l1"><a class="reference internal" href="../model_zoo_en.html">Model Zoo</a></li>
</ul>
</div>
</div>
</nav>
<section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">
<nav class="wy-nav-top" role="navigation" aria-label="top navigation">
<i data-toggle="wy-nav-top" class="fa fa-bars"></i>
<a href="../index_en.html">PaddleSlim</a>
</nav>
<div class="wy-nav-content">
<div class="rst-content">
<div role="navigation" aria-label="breadcrumbs navigation">
<ul class="wy-breadcrumbs">
<li><a href="../index_en.html">Docs</a> &raquo;</li>
<li><a href="index_en.html">Aadvanced Tutorials</a> &raquo;</li>
<li>Pruning of image classification model - sensitivity</li>
<li class="wy-breadcrumbs-aside">
<a href="../_sources/tutorials/image_classification_sensitivity_analysis_tutorial_en.md.txt" rel="nofollow"> View page source</a>
</li>
</ul>
<hr/>
</div>
<div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
<div itemprop="articleBody">
<div class="section" id="pruning-of-image-classification-model-sensitivity">
<h1>Pruning of image classification model - sensitivity<a class="headerlink" href="#pruning-of-image-classification-model-sensitivity" title="Permalink to this headline"></a></h1>
<p>In this tutorial, you will learn how to use <a class="reference external" href="https://paddlepaddle.github.io/PaddleSlim/api/prune_api/#sensitivity">sensitivity API of PaddleSlim</a> by a demo of MobileNetV1 model on MNIST dataset。
This tutorial following workflow:</p>
<ol class="arabic simple">
<li>Import dependency</li>
<li>Build model</li>
<li>Define data reader</li>
<li>Define function for test</li>
<li>Training model</li>
<li>Get names of parameter</li>
<li>Compute sensitivities</li>
<li>Pruning model</li>
</ol>
<div class="section" id="import-dependency">
<h2>1. Import dependency<a class="headerlink" href="#import-dependency" title="Permalink to this headline"></a></h2>
<p>PaddleSlim dependents on Paddle1.7. Please ensure that you have installed paddle correctly. Import Paddle and PaddleSlim as below:</p>
<div class="highlight-python"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">paddle</span>
<span class="kn">import</span> <span class="nn">paddle.fluid</span> <span class="k">as</span> <span class="nn">fluid</span>
<span class="kn">import</span> <span class="nn">paddleslim</span> <span class="k">as</span> <span class="nn">slim</span>
</pre></div>
</div>
</div>
<div class="section" id="build-model">
<h2>2. Build model<a class="headerlink" href="#build-model" title="Permalink to this headline"></a></h2>
<p>This section will build a classsification model based <code class="docutils literal"><span class="pre">MobileNetV1</span></code> for MNIST task. The shape of the input is <code class="docutils literal"><span class="pre">[1,</span> <span class="pre">28,</span> <span class="pre">28]</span></code> and the output number is 10.</p>
<p>To make the code simple, we define a function in package <code class="docutils literal"><span class="pre">paddleslim.models</span></code> to build classification model.
Excute following code to build a model,</p>
<div class="highlight-python"><div class="highlight"><pre><span></span><span class="n">exe</span><span class="p">,</span> <span class="n">train_program</span><span class="p">,</span> <span class="n">val_program</span><span class="p">,</span> <span class="n">inputs</span><span class="p">,</span> <span class="n">outputs</span> <span class="o">=</span> <span class="n">slim</span><span class="o">.</span><span class="n">models</span><span class="o">.</span><span class="n">image_classification</span><span class="p">(</span><span class="s2">&quot;MobileNet&quot;</span><span class="p">,</span> <span class="p">[</span><span class="mi">1</span><span class="p">,</span> <span class="mi">28</span><span class="p">,</span> <span class="mi">28</span><span class="p">],</span> <span class="mi">10</span><span class="p">,</span> <span class="n">use_gpu</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span>
<span class="n">place</span> <span class="o">=</span> <span class="n">fluid</span><span class="o">.</span><span class="n">CUDAPlace</span><span class="p">(</span><span class="mi">0</span><span class="p">)</span>
</pre></div>
</div>
<blockquote>
<div>Note:The functions in paddleslim.models is just used in tutorials or demos.</div></blockquote>
</div>
<div class="section" id="define-data-reader">
<h2>3 Define data reader<a class="headerlink" href="#define-data-reader" title="Permalink to this headline"></a></h2>
<p>MNIST dataset is used for making the demo can be executed quickly. It defines some functions for downloading and reading MNIST dataset in package <code class="docutils literal"><span class="pre">paddle.dataset.mnist</span></code>.
Show as below:</p>
<div class="highlight-python"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">paddle.dataset.mnist</span> <span class="k">as</span> <span class="nn">reader</span>
<span class="n">train_reader</span> <span class="o">=</span> <span class="n">paddle</span><span class="o">.</span><span class="n">batch</span><span class="p">(</span>
<span class="n">reader</span><span class="o">.</span><span class="n">train</span><span class="p">(),</span> <span class="n">batch_size</span><span class="o">=</span><span class="mi">128</span><span class="p">,</span> <span class="n">drop_last</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span>
<span class="n">test_reader</span> <span class="o">=</span> <span class="n">paddle</span><span class="o">.</span><span class="n">batch</span><span class="p">(</span>
<span class="n">reader</span><span class="o">.</span><span class="n">test</span><span class="p">(),</span> <span class="n">batch_size</span><span class="o">=</span><span class="mi">128</span><span class="p">,</span> <span class="n">drop_last</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span>
<span class="n">data_feeder</span> <span class="o">=</span> <span class="n">fluid</span><span class="o">.</span><span class="n">DataFeeder</span><span class="p">(</span><span class="n">inputs</span><span class="p">,</span> <span class="n">place</span><span class="p">)</span>
</pre></div>
</div>
</div>
<div class="section" id="define-test-function">
<h2>4. Define test function<a class="headerlink" href="#define-test-function" title="Permalink to this headline"></a></h2>
<p>To get the performance of model on test dataset after pruning a convolution layer, we define a test function as below:</p>
<div class="highlight-python"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">numpy</span> <span class="k">as</span> <span class="nn">np</span>
<span class="k">def</span> <span class="nf">test</span><span class="p">(</span><span class="n">program</span><span class="p">):</span>
<span class="n">acc_top1_ns</span> <span class="o">=</span> <span class="p">[]</span>
<span class="n">acc_top5_ns</span> <span class="o">=</span> <span class="p">[]</span>
<span class="k">for</span> <span class="n">data</span> <span class="ow">in</span> <span class="n">test_reader</span><span class="p">():</span>
<span class="n">acc_top1_n</span><span class="p">,</span> <span class="n">acc_top5_n</span><span class="p">,</span> <span class="n">_</span> <span class="o">=</span> <span class="n">exe</span><span class="o">.</span><span class="n">run</span><span class="p">(</span>
<span class="n">program</span><span class="p">,</span>
<span class="n">feed</span><span class="o">=</span><span class="n">data_feeder</span><span class="o">.</span><span class="n">feed</span><span class="p">(</span><span class="n">data</span><span class="p">),</span>
<span class="n">fetch_list</span><span class="o">=</span><span class="n">outputs</span><span class="p">)</span>
<span class="n">acc_top1_ns</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">np</span><span class="o">.</span><span class="n">mean</span><span class="p">(</span><span class="n">acc_top1_n</span><span class="p">))</span>
<span class="n">acc_top5_ns</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">np</span><span class="o">.</span><span class="n">mean</span><span class="p">(</span><span class="n">acc_top5_n</span><span class="p">))</span>
<span class="nb">print</span><span class="p">(</span><span class="s2">&quot;Final eva - acc_top1: </span><span class="si">{}</span><span class="s2">; acc_top5: </span><span class="si">{}</span><span class="s2">&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span>
<span class="n">np</span><span class="o">.</span><span class="n">mean</span><span class="p">(</span><span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">(</span><span class="n">acc_top1_ns</span><span class="p">)),</span> <span class="n">np</span><span class="o">.</span><span class="n">mean</span><span class="p">(</span><span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">(</span><span class="n">acc_top5_ns</span><span class="p">))))</span>
<span class="k">return</span> <span class="n">np</span><span class="o">.</span><span class="n">mean</span><span class="p">(</span><span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">(</span><span class="n">acc_top1_ns</span><span class="p">))</span>
</pre></div>
</div>
</div>
<div class="section" id="training-model">
<h2>5. Training model<a class="headerlink" href="#training-model" title="Permalink to this headline"></a></h2>
<p>Sensitivity analysis is dependent on pretrained model. So we should train the model defined in section 2 for some epochs. One epoch training is enough for this simple demo while more epochs may be necessary for other model. Or you can load pretrained model from filesystem.</p>
<p>Training model as below:</p>
<div class="highlight-python"><div class="highlight"><pre><span></span><span class="k">for</span> <span class="n">data</span> <span class="ow">in</span> <span class="n">train_reader</span><span class="p">():</span>
<span class="n">acc1</span><span class="p">,</span> <span class="n">acc5</span><span class="p">,</span> <span class="n">loss</span> <span class="o">=</span> <span class="n">exe</span><span class="o">.</span><span class="n">run</span><span class="p">(</span><span class="n">train_program</span><span class="p">,</span> <span class="n">feed</span><span class="o">=</span><span class="n">data_feeder</span><span class="o">.</span><span class="n">feed</span><span class="p">(</span><span class="n">data</span><span class="p">),</span> <span class="n">fetch_list</span><span class="o">=</span><span class="n">outputs</span><span class="p">)</span>
<span class="nb">print</span><span class="p">(</span><span class="n">np</span><span class="o">.</span><span class="n">mean</span><span class="p">(</span><span class="n">acc1</span><span class="p">),</span> <span class="n">np</span><span class="o">.</span><span class="n">mean</span><span class="p">(</span><span class="n">acc5</span><span class="p">),</span> <span class="n">np</span><span class="o">.</span><span class="n">mean</span><span class="p">(</span><span class="n">loss</span><span class="p">))</span>
</pre></div>
</div>
<p>Get the performance using the test function defined in section 4:</p>
<div class="highlight-python"><div class="highlight"><pre><span></span><span class="n">test</span><span class="p">(</span><span class="n">val_program</span><span class="p">)</span>
</pre></div>
</div>
</div>
<div class="section" id="get-names-of-parameters">
<h2>6. Get names of parameters<a class="headerlink" href="#get-names-of-parameters" title="Permalink to this headline"></a></h2>
<div class="highlight-python"><div class="highlight"><pre><span></span><span class="n">params</span> <span class="o">=</span> <span class="p">[]</span>
<span class="k">for</span> <span class="n">param</span> <span class="ow">in</span> <span class="n">train_program</span><span class="o">.</span><span class="n">global_block</span><span class="p">()</span><span class="o">.</span><span class="n">all_parameters</span><span class="p">():</span>
<span class="k">if</span> <span class="s2">&quot;_sep_weights&quot;</span> <span class="ow">in</span> <span class="n">param</span><span class="o">.</span><span class="n">name</span><span class="p">:</span>
<span class="n">params</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">param</span><span class="o">.</span><span class="n">name</span><span class="p">)</span>
<span class="nb">print</span><span class="p">(</span><span class="n">params</span><span class="p">)</span>
<span class="n">params</span> <span class="o">=</span> <span class="n">params</span><span class="p">[:</span><span class="mi">5</span><span class="p">]</span>
</pre></div>
</div>
</div>
<div class="section" id="compute-sensitivities">
<h2>7. Compute sensitivities<a class="headerlink" href="#compute-sensitivities" title="Permalink to this headline"></a></h2>
<div class="section" id="compute-in-single-process">
<h3>7.1 Compute in single process<a class="headerlink" href="#compute-in-single-process" title="Permalink to this headline"></a></h3>
<p>Apply sensitivity analysis on pretrained model by calling <a class="reference external" href="https://paddlepaddle.github.io/PaddleSlim/api/prune_api/#sensitivity">sensitivity API</a>.</p>
<p>The sensitivities will be appended into the file given by option <code class="docutils literal"><span class="pre">sensitivities_file</span></code> during computing.
The information in this file won`t be computed repeatedly.</p>
<p>Remove the file <code class="docutils literal"><span class="pre">sensitivities_0.data</span></code> in current directory:</p>
<div class="highlight-python"><div class="highlight"><pre><span></span>!rm -rf sensitivities_0.data
</pre></div>
</div>
<p>Apart from the parameters to be analyzed, it also support for setting the ratios that each convolutoin will be pruned.</p>
<p>If one model losses 90% accuracy on test dataset when its single convolution layer is pruned by 40%, then we can set <code class="docutils literal"><span class="pre">pruned_ratios</span></code> to <code class="docutils literal"><span class="pre">[0.1,</span> <span class="pre">0.2,</span> <span class="pre">0.3,</span> <span class="pre">0.4]</span></code>.</p>
<p>The granularity of <code class="docutils literal"><span class="pre">pruned_ratios</span></code> should be small to get more reasonable sensitivities. But small granularity of <code class="docutils literal"><span class="pre">pruned_ratios</span></code> will slow down the computing.</p>
<div class="highlight-python"><div class="highlight"><pre><span></span><span class="n">sens_0</span> <span class="o">=</span> <span class="n">slim</span><span class="o">.</span><span class="n">prune</span><span class="o">.</span><span class="n">sensitivity</span><span class="p">(</span>
<span class="n">val_program</span><span class="p">,</span>
<span class="n">place</span><span class="p">,</span>
<span class="n">params</span><span class="p">,</span>
<span class="n">test</span><span class="p">,</span>
<span class="n">sensitivities_file</span><span class="o">=</span><span class="s2">&quot;sensitivities_0.data&quot;</span><span class="p">,</span>
<span class="n">pruned_ratios</span><span class="o">=</span><span class="p">[</span><span class="mf">0.1</span><span class="p">,</span> <span class="mf">0.2</span><span class="p">])</span>
<span class="nb">print</span><span class="p">(</span><span class="n">sens_0</span><span class="p">)</span>
</pre></div>
</div>
</div>
<div class="section" id="expand-sensitivities">
<h3>7.2 Expand sensitivities<a class="headerlink" href="#expand-sensitivities" title="Permalink to this headline"></a></h3>
<p>We can expand <code class="docutils literal"><span class="pre">pruned_ratios</span></code> to <code class="docutils literal"><span class="pre">[0.1,</span> <span class="pre">0.2,</span> <span class="pre">0.3]</span></code> based the sensitivities generated in section 7.1.</p>
<div class="highlight-python"><div class="highlight"><pre><span></span><span class="n">sens_0</span> <span class="o">=</span> <span class="n">slim</span><span class="o">.</span><span class="n">prune</span><span class="o">.</span><span class="n">sensitivity</span><span class="p">(</span>
<span class="n">val_program</span><span class="p">,</span>
<span class="n">place</span><span class="p">,</span>
<span class="n">params</span><span class="p">,</span>
<span class="n">test</span><span class="p">,</span>
<span class="n">sensitivities_file</span><span class="o">=</span><span class="s2">&quot;sensitivities_0.data&quot;</span><span class="p">,</span>
<span class="n">pruned_ratios</span><span class="o">=</span><span class="p">[</span><span class="mf">0.3</span><span class="p">])</span>
<span class="nb">print</span><span class="p">(</span><span class="n">sens_0</span><span class="p">)</span>
</pre></div>
</div>
</div>
<div class="section" id="computing-sensitivity-in-multi-process">
<h3>7.3 Computing sensitivity in multi-process<a class="headerlink" href="#computing-sensitivity-in-multi-process" title="Permalink to this headline"></a></h3>
<p>The time cost of computing sensitivities is dependent on the count of parameters and the speed of model evaluation on test dataset. We can speed up computing by multi-process.</p>
<p>Split <code class="docutils literal"><span class="pre">pruned_ratios</span></code> into multi-process, and merge the sensitivities from multi-process.</p>
<div class="section" id="computing-in-each-process">
<h4>7.3.1 Computing in each process<a class="headerlink" href="#computing-in-each-process" title="Permalink to this headline"></a></h4>
<p>We have compute the sensitivities when <code class="docutils literal"><span class="pre">pruned_ratios=[0.1,</span> <span class="pre">0.2,</span> <span class="pre">0.3]</span></code> and saved the sensitivities into file named <code class="docutils literal"><span class="pre">sensitivities_0.data</span></code>.</p>
<p>在另一个进程中,The we start a task by setting <code class="docutils literal"><span class="pre">pruned_ratios=[0.4]</span></code> in another process and save result into file named <code class="docutils literal"><span class="pre">sensitivities_1.data</span></code>. Show as below:</p>
<div class="highlight-python"><div class="highlight"><pre><span></span><span class="n">sens_1</span> <span class="o">=</span> <span class="n">slim</span><span class="o">.</span><span class="n">prune</span><span class="o">.</span><span class="n">sensitivity</span><span class="p">(</span>
<span class="n">val_program</span><span class="p">,</span>
<span class="n">place</span><span class="p">,</span>
<span class="n">params</span><span class="p">,</span>
<span class="n">test</span><span class="p">,</span>
<span class="n">sensitivities_file</span><span class="o">=</span><span class="s2">&quot;sensitivities_1.data&quot;</span><span class="p">,</span>
<span class="n">pruned_ratios</span><span class="o">=</span><span class="p">[</span><span class="mf">0.4</span><span class="p">])</span>
<span class="nb">print</span><span class="p">(</span><span class="n">sens_1</span><span class="p">)</span>
</pre></div>
</div>
</div>
<div class="section" id="load-sensitivity-file-generated-in-multi-process">
<h4>7.3.2 Load sensitivity file generated in multi-process<a class="headerlink" href="#load-sensitivity-file-generated-in-multi-process" title="Permalink to this headline"></a></h4>
<div class="highlight-python"><div class="highlight"><pre><span></span><span class="n">s_0</span> <span class="o">=</span> <span class="n">slim</span><span class="o">.</span><span class="n">prune</span><span class="o">.</span><span class="n">load_sensitivities</span><span class="p">(</span><span class="s2">&quot;sensitivities_0.data&quot;</span><span class="p">)</span>
<span class="n">s_1</span> <span class="o">=</span> <span class="n">slim</span><span class="o">.</span><span class="n">prune</span><span class="o">.</span><span class="n">load_sensitivities</span><span class="p">(</span><span class="s2">&quot;sensitivities_1.data&quot;</span><span class="p">)</span>
<span class="nb">print</span><span class="p">(</span><span class="n">s_0</span><span class="p">)</span>
<span class="nb">print</span><span class="p">(</span><span class="n">s_1</span><span class="p">)</span>
</pre></div>
</div>
</div>
<div class="section" id="merge-sensitivies">
<h4>7.3.3 Merge sensitivies<a class="headerlink" href="#merge-sensitivies" title="Permalink to this headline"></a></h4>
<div class="highlight-python"><div class="highlight"><pre><span></span><span class="n">s</span> <span class="o">=</span> <span class="n">slim</span><span class="o">.</span><span class="n">prune</span><span class="o">.</span><span class="n">merge_sensitive</span><span class="p">([</span><span class="n">s_0</span><span class="p">,</span> <span class="n">s_1</span><span class="p">])</span>
<span class="nb">print</span><span class="p">(</span><span class="n">s</span><span class="p">)</span>
</pre></div>
</div>
</div>
</div>
</div>
<div class="section" id="pruning-model">
<h2>8. Pruning model<a class="headerlink" href="#pruning-model" title="Permalink to this headline"></a></h2>
<p>Pruning model according to the sensitivities generated in section 7.3.3.</p>
<div class="section" id="get-pruning-ratios">
<h3>8.1 Get pruning ratios<a class="headerlink" href="#get-pruning-ratios" title="Permalink to this headline"></a></h3>
<p>Get a group of ratios by calling <a class="reference external" href="https://paddlepaddle.github.io/PaddleSlim/api/prune_api/#get_ratios_by_loss">get_ratios_by_loss</a> fuction:</p>
<div class="highlight-python"><div class="highlight"><pre><span></span><span class="n">loss</span> <span class="o">=</span> <span class="mf">0.01</span>
<span class="n">ratios</span> <span class="o">=</span> <span class="n">slim</span><span class="o">.</span><span class="n">prune</span><span class="o">.</span><span class="n">get_ratios_by_loss</span><span class="p">(</span><span class="n">s_0</span><span class="p">,</span> <span class="n">loss</span><span class="p">)</span>
<span class="nb">print</span><span class="p">(</span><span class="n">ratios</span><span class="p">)</span>
</pre></div>
</div>
</div>
<div class="section" id="pruning-training-network">
<h3>8.2 Pruning training network<a class="headerlink" href="#pruning-training-network" title="Permalink to this headline"></a></h3>
<div class="highlight-python"><div class="highlight"><pre><span></span><span class="n">pruner</span> <span class="o">=</span> <span class="n">slim</span><span class="o">.</span><span class="n">prune</span><span class="o">.</span><span class="n">Pruner</span><span class="p">()</span>
<span class="nb">print</span><span class="p">(</span><span class="s2">&quot;FLOPs before pruning: </span><span class="si">{}</span><span class="s2">&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">slim</span><span class="o">.</span><span class="n">analysis</span><span class="o">.</span><span class="n">flops</span><span class="p">(</span><span class="n">train_program</span><span class="p">)))</span>
<span class="n">pruned_program</span><span class="p">,</span> <span class="n">_</span><span class="p">,</span> <span class="n">_</span> <span class="o">=</span> <span class="n">pruner</span><span class="o">.</span><span class="n">prune</span><span class="p">(</span>
<span class="n">train_program</span><span class="p">,</span>
<span class="n">fluid</span><span class="o">.</span><span class="n">global_scope</span><span class="p">(),</span>
<span class="n">params</span><span class="o">=</span><span class="n">ratios</span><span class="o">.</span><span class="n">keys</span><span class="p">(),</span>
<span class="n">ratios</span><span class="o">=</span><span class="n">ratios</span><span class="o">.</span><span class="n">values</span><span class="p">(),</span>
<span class="n">place</span><span class="o">=</span><span class="n">place</span><span class="p">)</span>
<span class="nb">print</span><span class="p">(</span><span class="s2">&quot;FLOPs after pruning: </span><span class="si">{}</span><span class="s2">&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">slim</span><span class="o">.</span><span class="n">analysis</span><span class="o">.</span><span class="n">flops</span><span class="p">(</span><span class="n">pruned_program</span><span class="p">)))</span>
</pre></div>
</div>
</div>
<div class="section" id="pruning-test-network">
<h3>8.3 Pruning test network<a class="headerlink" href="#pruning-test-network" title="Permalink to this headline"></a></h3>
<p>Note:The <code class="docutils literal"><span class="pre">only_graph</span></code> should be set to True while pruning test network. <a class="reference external" href="https://paddlepaddle.github.io/PaddleSlim/api/prune_api/#pruner">Pruner API</a></p>
<div class="highlight-python"><div class="highlight"><pre><span></span><span class="n">pruner</span> <span class="o">=</span> <span class="n">slim</span><span class="o">.</span><span class="n">prune</span><span class="o">.</span><span class="n">Pruner</span><span class="p">()</span>
<span class="nb">print</span><span class="p">(</span><span class="s2">&quot;FLOPs before pruning: </span><span class="si">{}</span><span class="s2">&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">slim</span><span class="o">.</span><span class="n">analysis</span><span class="o">.</span><span class="n">flops</span><span class="p">(</span><span class="n">val_program</span><span class="p">)))</span>
<span class="n">pruned_val_program</span><span class="p">,</span> <span class="n">_</span><span class="p">,</span> <span class="n">_</span> <span class="o">=</span> <span class="n">pruner</span><span class="o">.</span><span class="n">prune</span><span class="p">(</span>
<span class="n">val_program</span><span class="p">,</span>
<span class="n">fluid</span><span class="o">.</span><span class="n">global_scope</span><span class="p">(),</span>
<span class="n">params</span><span class="o">=</span><span class="n">ratios</span><span class="o">.</span><span class="n">keys</span><span class="p">(),</span>
<span class="n">ratios</span><span class="o">=</span><span class="n">ratios</span><span class="o">.</span><span class="n">values</span><span class="p">(),</span>
<span class="n">place</span><span class="o">=</span><span class="n">place</span><span class="p">,</span>
<span class="n">only_graph</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span>
<span class="nb">print</span><span class="p">(</span><span class="s2">&quot;FLOPs after pruning: </span><span class="si">{}</span><span class="s2">&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">slim</span><span class="o">.</span><span class="n">analysis</span><span class="o">.</span><span class="n">flops</span><span class="p">(</span><span class="n">pruned_val_program</span><span class="p">)))</span>
</pre></div>
</div>
<p>Get accuracy of pruned model on test dataset:</p>
<div class="highlight-python"><div class="highlight"><pre><span></span><span class="n">test</span><span class="p">(</span><span class="n">pruned_val_program</span><span class="p">)</span>
</pre></div>
</div>
</div>
<div class="section" id="training-pruned-model">
<h3>8.4 Training pruned model<a class="headerlink" href="#training-pruned-model" title="Permalink to this headline"></a></h3>
<p>Training pruned model:</p>
<div class="highlight-python"><div class="highlight"><pre><span></span><span class="k">for</span> <span class="n">data</span> <span class="ow">in</span> <span class="n">train_reader</span><span class="p">():</span>
<span class="n">acc1</span><span class="p">,</span> <span class="n">acc5</span><span class="p">,</span> <span class="n">loss</span> <span class="o">=</span> <span class="n">exe</span><span class="o">.</span><span class="n">run</span><span class="p">(</span><span class="n">pruned_program</span><span class="p">,</span> <span class="n">feed</span><span class="o">=</span><span class="n">data_feeder</span><span class="o">.</span><span class="n">feed</span><span class="p">(</span><span class="n">data</span><span class="p">),</span> <span class="n">fetch_list</span><span class="o">=</span><span class="n">outputs</span><span class="p">)</span>
<span class="nb">print</span><span class="p">(</span><span class="n">np</span><span class="o">.</span><span class="n">mean</span><span class="p">(</span><span class="n">acc1</span><span class="p">),</span> <span class="n">np</span><span class="o">.</span><span class="n">mean</span><span class="p">(</span><span class="n">acc5</span><span class="p">),</span> <span class="n">np</span><span class="o">.</span><span class="n">mean</span><span class="p">(</span><span class="n">loss</span><span class="p">))</span>
</pre></div>
</div>
<p>Get accuracy of model after training:</p>
<div class="highlight-python"><div class="highlight"><pre><span></span><span class="n">test</span><span class="p">(</span><span class="n">pruned_val_program</span><span class="p">)</span>
</pre></div>
</div>
</div>
</div>
</div>
</div>
</div>
<footer>
<div class="rst-footer-buttons" role="navigation" aria-label="footer navigation">
<a href="../api_en/index_en.html" class="btn btn-neutral float-right" title="API Documents" accesskey="n">Next <span class="fa fa-arrow-circle-right"></span></a>
<a href="index_en.html" class="btn btn-neutral" title="Aadvanced Tutorials" accesskey="p"><span class="fa fa-arrow-circle-left"></span> Previous</a>
</div>
<hr/>
<div role="contentinfo">
<p>
&copy; Copyright 2020, paddleslim.
</p>
</div>
Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/snide/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>.
</footer>
</div>
</div>
</section>
</div>
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT:'../',
VERSION:'1.0',
COLLAPSE_INDEX:false,
FILE_SUFFIX:'.html',
HAS_SOURCE: true
};
</script>
<script type="text/javascript" src="../_static/jquery.js"></script>
<script type="text/javascript" src="../_static/underscore.js"></script>
<script type="text/javascript" src="../_static/doctools.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
<script type="text/javascript" src="../_static/js/theme.js"></script>
<script type="text/javascript">
jQuery(function () {
SphinxRtdTheme.StickyNav.enable();
});
</script>
</body>
</html>
\ No newline at end of file
...@@ -82,11 +82,18 @@ ...@@ -82,11 +82,18 @@
<ul class="current"> <ul class="current">
<li class="toctree-l1"><a class="reference internal" href="../index_en.html">English Documents</a></li> <li class="toctree-l1"><a class="reference internal" href="../index_en.html">English Documents</a></li>
<li class="toctree-l1"><a class="reference internal" href="../intro.html">PaddleSlim简介</a></li> <li class="toctree-l1"><a class="reference internal" href="../intro.html">介绍</a></li>
<li class="toctree-l1"><a class="reference internal" href="../install.html">安装</a></li> <li class="toctree-l1"><a class="reference internal" href="../install.html">安装</a></li>
<li class="toctree-l1"><a class="reference internal" href="../quick_start/index.html">快速开始</a></li> <li class="toctree-l1"><a class="reference internal" href="../quick_start/index.html">快速开始</a></li>
<li class="toctree-l1 current"><a class="current reference internal" href="#">进阶教程</a><ul> <li class="toctree-l1 current"><a class="current reference internal" href="#">进阶教程</a><ul>
<li class="toctree-l2"><a class="reference internal" href="image_classification_sensitivity_analysis_tutorial.html">图像分类模型通道剪裁-敏感度分析</a></li> <li class="toctree-l2"><a class="reference internal" href="image_classification_sensitivity_analysis_tutorial.html">图像分类模型通道剪裁-敏感度分析</a></li>
<li class="toctree-l2"><a class="reference internal" href="darts_nas_turorial.html">SANAS进阶版实验教程-压缩DARTS产出模型</a></li>
<li class="toctree-l2"><a class="reference internal" href="paddledetection_slim_distillation_tutorial.html">目标检测模型蒸馏教程</a></li>
<li class="toctree-l2"><a class="reference internal" href="paddledetection_slim_nas_tutorial.html">人脸检测模型小模型结构搜索教程</a></li>
<li class="toctree-l2"><a class="reference internal" href="paddledetection_slim_pruing_tutorial.html">目标检测模型卷积通道剪裁教程</a></li>
<li class="toctree-l2"><a class="reference internal" href="paddledetection_slim_prune_dist_tutorial.html">目标检测模型蒸馏剪裁教程</a></li>
<li class="toctree-l2"><a class="reference internal" href="paddledetection_slim_quantization_tutorial.html">目标检测模型定点量化教程</a></li>
<li class="toctree-l2"><a class="reference internal" href="paddledetection_slim_sensitivy_tutorial.html">目标检测模型敏感度分析教程</a></li>
</ul> </ul>
</li> </li>
<li class="toctree-l1"><a class="reference internal" href="../api_cn/index.html">API文档</a></li> <li class="toctree-l1"><a class="reference internal" href="../api_cn/index.html">API文档</a></li>
...@@ -139,19 +146,15 @@ ...@@ -139,19 +146,15 @@
<div class="section" id="id1"> <div class="section" id="id1">
<h1>进阶教程<a class="headerlink" href="#id1" title="永久链接至标题"></a></h1> <h1>进阶教程<a class="headerlink" href="#id1" title="永久链接至标题"></a></h1>
<div class="toctree-wrapper compound"> <div class="toctree-wrapper compound">
<p class="caption"><span class="caption-text">Contents:</span></p>
<ul> <ul>
<li class="toctree-l1"><a class="reference internal" href="image_classification_sensitivity_analysis_tutorial.html">图像分类模型通道剪裁-敏感度分析</a><ul> <li class="toctree-l1"><a class="reference internal" href="image_classification_sensitivity_analysis_tutorial.html">图像分类模型通道剪裁-敏感度分析</a></li>
<li class="toctree-l2"><a class="reference internal" href="image_classification_sensitivity_analysis_tutorial.html#id2">1. 导入依赖</a></li> <li class="toctree-l1"><a class="reference internal" href="darts_nas_turorial.html">SANAS进阶版实验教程-压缩DARTS产出模型</a></li>
<li class="toctree-l2"><a class="reference internal" href="image_classification_sensitivity_analysis_tutorial.html#id3">2. 构建网络</a></li> <li class="toctree-l1"><a class="reference internal" href="paddledetection_slim_distillation_tutorial.html">目标检测模型蒸馏教程</a></li>
<li class="toctree-l2"><a class="reference internal" href="image_classification_sensitivity_analysis_tutorial.html#id4">3 定义输入数据</a></li> <li class="toctree-l1"><a class="reference internal" href="paddledetection_slim_nas_tutorial.html">人脸检测模型小模型结构搜索教程</a></li>
<li class="toctree-l2"><a class="reference internal" href="image_classification_sensitivity_analysis_tutorial.html#id5">4. 定义模型评估方法</a></li> <li class="toctree-l1"><a class="reference internal" href="paddledetection_slim_pruing_tutorial.html">目标检测模型卷积通道剪裁教程</a></li>
<li class="toctree-l2"><a class="reference internal" href="image_classification_sensitivity_analysis_tutorial.html#id6">5. 训练模型</a></li> <li class="toctree-l1"><a class="reference internal" href="paddledetection_slim_prune_dist_tutorial.html">目标检测模型蒸馏剪裁教程</a></li>
<li class="toctree-l2"><a class="reference internal" href="image_classification_sensitivity_analysis_tutorial.html#id7">6. 获取待分析卷积参数</a></li> <li class="toctree-l1"><a class="reference internal" href="paddledetection_slim_quantization_tutorial.html">目标检测模型定点量化教程</a></li>
<li class="toctree-l2"><a class="reference internal" href="image_classification_sensitivity_analysis_tutorial.html#id8">7. 分析敏感度</a></li> <li class="toctree-l1"><a class="reference internal" href="paddledetection_slim_sensitivy_tutorial.html">目标检测模型敏感度分析教程</a></li>
<li class="toctree-l2"><a class="reference internal" href="image_classification_sensitivity_analysis_tutorial.html#id15">8. 剪裁模型</a></li>
</ul>
</li>
</ul> </ul>
</div> </div>
</div> </div>
......
...@@ -34,7 +34,7 @@ ...@@ -34,7 +34,7 @@
href="../genindex.html"/> href="../genindex.html"/>
<link rel="search" title="Search" href="../search.html"/> <link rel="search" title="Search" href="../search.html"/>
<link rel="top" title="PaddleSlim 1.0 documentation" href="../index.html"/> <link rel="top" title="PaddleSlim 1.0 documentation" href="../index.html"/>
<link rel="next" title="Pruning of image classification model - sensitivity" href="sensitivity_tutorial_en.html"/> <link rel="next" title="Pruning of image classification model - sensitivity" href="image_classification_sensitivity_analysis_tutorial_en.html"/>
<link rel="prev" title="Post-training Quantization of image classification model - quick start" href="../quick_start/quant_post_tutorial_en.html"/> <link rel="prev" title="Post-training Quantization of image classification model - quick start" href="../quick_start/quant_post_tutorial_en.html"/>
...@@ -86,7 +86,7 @@ ...@@ -86,7 +86,7 @@
<li class="toctree-l1"><a class="reference internal" href="../install_en.html">Install</a></li> <li class="toctree-l1"><a class="reference internal" href="../install_en.html">Install</a></li>
<li class="toctree-l1"><a class="reference internal" href="../quick_start/index_en.html">Quick Start</a></li> <li class="toctree-l1"><a class="reference internal" href="../quick_start/index_en.html">Quick Start</a></li>
<li class="toctree-l1 current"><a class="current reference internal" href="#">Aadvanced Tutorials</a><ul> <li class="toctree-l1 current"><a class="current reference internal" href="#">Aadvanced Tutorials</a><ul>
<li class="toctree-l2"><a class="reference internal" href="sensitivity_tutorial_en.html">Pruning of image classification model - sensitivity</a></li> <li class="toctree-l2"><a class="reference internal" href="image_classification_sensitivity_analysis_tutorial_en.html">Pruning of image classification model - sensitivity</a></li>
</ul> </ul>
</li> </li>
<li class="toctree-l1"><a class="reference internal" href="../api_en/index_en.html">API Documents</a></li> <li class="toctree-l1"><a class="reference internal" href="../api_en/index_en.html">API Documents</a></li>
...@@ -139,7 +139,7 @@ ...@@ -139,7 +139,7 @@
<h1>Aadvanced Tutorials<a class="headerlink" href="#aadvanced-tutorials" title="Permalink to this headline"></a></h1> <h1>Aadvanced Tutorials<a class="headerlink" href="#aadvanced-tutorials" title="Permalink to this headline"></a></h1>
<div class="toctree-wrapper compound"> <div class="toctree-wrapper compound">
<ul> <ul>
<li class="toctree-l1"><a class="reference internal" href="sensitivity_tutorial_en.html">Pruning of image classification model - sensitivity</a></li> <li class="toctree-l1"><a class="reference internal" href="image_classification_sensitivity_analysis_tutorial_en.html">Pruning of image classification model - sensitivity</a></li>
</ul> </ul>
</div> </div>
</div> </div>
...@@ -151,7 +151,7 @@ ...@@ -151,7 +151,7 @@
<div class="rst-footer-buttons" role="navigation" aria-label="footer navigation"> <div class="rst-footer-buttons" role="navigation" aria-label="footer navigation">
<a href="sensitivity_tutorial_en.html" class="btn btn-neutral float-right" title="Pruning of image classification model - sensitivity" accesskey="n">Next <span class="fa fa-arrow-circle-right"></span></a> <a href="image_classification_sensitivity_analysis_tutorial_en.html" class="btn btn-neutral float-right" title="Pruning of image classification model - sensitivity" accesskey="n">Next <span class="fa fa-arrow-circle-right"></span></a>
<a href="../quick_start/quant_post_tutorial_en.html" class="btn btn-neutral" title="Post-training Quantization of image classification model - quick start" accesskey="p"><span class="fa fa-arrow-circle-left"></span> Previous</a> <a href="../quick_start/quant_post_tutorial_en.html" class="btn btn-neutral" title="Post-training Quantization of image classification model - quick start" accesskey="p"><span class="fa fa-arrow-circle-left"></span> Previous</a>
......
<!DOCTYPE html>
<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]-->
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>目标检测模型蒸馏教程 &mdash; PaddleSlim 1.0 文档</title>
<link rel="stylesheet" href="../_static/css/theme.css" type="text/css" />
<link rel="index" title="索引"
href="../genindex.html"/>
<link rel="search" title="搜索" href="../search.html"/>
<link rel="top" title="PaddleSlim 1.0 文档" href="../index.html"/>
<link rel="up" title="进阶教程" href="index.html"/>
<link rel="next" title="人脸检测模型小模型结构搜索教程" href="paddledetection_slim_nas_tutorial.html"/>
<link rel="prev" title="SANAS进阶版实验教程-压缩DARTS产出模型" href="darts_nas_turorial.html"/>
<script src="../_static/js/modernizr.min.js"></script>
</head>
<body class="wy-body-for-nav" role="document">
<div class="wy-grid-for-nav">
<nav data-toggle="wy-nav-shift" class="wy-nav-side">
<div class="wy-side-scroll">
<div class="wy-side-nav-search">
<a href="../index.html" class="icon icon-home"> PaddleSlim
</a>
<div role="search">
<form id="rtd-search-form" class="wy-form" action="../search.html" method="get">
<input type="text" name="q" placeholder="Search docs" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
</div>
</div>
<div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
<ul class="current">
<li class="toctree-l1"><a class="reference internal" href="../index_en.html">English Documents</a></li>
<li class="toctree-l1"><a class="reference internal" href="../intro.html">介绍</a></li>
<li class="toctree-l1"><a class="reference internal" href="../install.html">安装</a></li>
<li class="toctree-l1"><a class="reference internal" href="../quick_start/index.html">快速开始</a></li>
<li class="toctree-l1 current"><a class="reference internal" href="index.html">进阶教程</a><ul class="current">
<li class="toctree-l2"><a class="reference internal" href="image_classification_sensitivity_analysis_tutorial.html">图像分类模型通道剪裁-敏感度分析</a></li>
<li class="toctree-l2"><a class="reference internal" href="darts_nas_turorial.html">SANAS进阶版实验教程-压缩DARTS产出模型</a></li>
<li class="toctree-l2 current"><a class="current reference internal" href="#">目标检测模型蒸馏教程</a><ul>
<li class="toctree-l3"><a class="reference internal" href="#id2">示例结果</a><ul>
<li class="toctree-l4"><a class="reference internal" href="#mobilenetv1-yolo-v3-voc">MobileNetV1-YOLO-V3-VOC</a></li>
<li class="toctree-l4"><a class="reference internal" href="#mobilenetv1-yolo-v3-coco">MobileNetV1-YOLO-V3-COCO</a></li>
</ul>
</li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="paddledetection_slim_nas_tutorial.html">人脸检测模型小模型结构搜索教程</a></li>
<li class="toctree-l2"><a class="reference internal" href="paddledetection_slim_pruing_tutorial.html">目标检测模型卷积通道剪裁教程</a></li>
<li class="toctree-l2"><a class="reference internal" href="paddledetection_slim_prune_dist_tutorial.html">目标检测模型蒸馏剪裁教程</a></li>
<li class="toctree-l2"><a class="reference internal" href="paddledetection_slim_quantization_tutorial.html">目标检测模型定点量化教程</a></li>
<li class="toctree-l2"><a class="reference internal" href="paddledetection_slim_sensitivy_tutorial.html">目标检测模型敏感度分析教程</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../api_cn/index.html">API文档</a></li>
<li class="toctree-l1"><a class="reference internal" href="../model_zoo.html">模型库</a></li>
<li class="toctree-l1"><a class="reference internal" href="../algo/algo.html">算法原理</a></li>
</ul>
</div>
</div>
</nav>
<section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">
<nav class="wy-nav-top" role="navigation" aria-label="top navigation">
<i data-toggle="wy-nav-top" class="fa fa-bars"></i>
<a href="../index.html">PaddleSlim</a>
</nav>
<div class="wy-nav-content">
<div class="rst-content">
<div role="navigation" aria-label="breadcrumbs navigation">
<ul class="wy-breadcrumbs">
<li><a href="../index.html">Docs</a> &raquo;</li>
<li><a href="index.html">进阶教程</a> &raquo;</li>
<li>目标检测模型蒸馏教程</li>
<li class="wy-breadcrumbs-aside">
<a href="../_sources/tutorials/paddledetection_slim_distillation_tutorial.md.txt" rel="nofollow"> View page source</a>
</li>
</ul>
<hr/>
</div>
<div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
<div itemprop="articleBody">
<div class="section" id="id1">
<h1>目标检测模型蒸馏教程<a class="headerlink" href="#id1" title="永久链接至标题"></a></h1>
<p>教程内容请参考:<a class="reference external" href="https://github.com/PaddlePaddle/PaddleDetection/blob/release/0.2/slim/distillation/README.md">https://github.com/PaddlePaddle/PaddleDetection/blob/release/0.2/slim/distillation/README.md</a></p>
<div class="section" id="id2">
<h2>示例结果<a class="headerlink" href="#id2" title="永久链接至标题"></a></h2>
<div class="section" id="mobilenetv1-yolo-v3-voc">
<h3>MobileNetV1-YOLO-V3-VOC<a class="headerlink" href="#mobilenetv1-yolo-v3-voc" title="永久链接至标题"></a></h3>
<table border="1" class="docutils">
<thead>
<tr>
<th align="center">FLOPS</th>
<th align="center">输入尺寸</th>
<th align="center">每张GPU图片个数</th>
<th align="center">推理时间(fps)</th>
<th align="center">Box AP</th>
<th align="center">下载</th>
</tr>
</thead>
<tbody>
<tr>
<td align="center">baseline</td>
<td align="center">608</td>
<td align="center">16</td>
<td align="center">104.291</td>
<td align="center">76.2</td>
<td align="center"><a href="https://paddlemodels.bj.bcebos.com/object_detection/yolov3_mobilenet_v1_voc.tar">下载链接</a></td>
</tr>
<tr>
<td align="center">蒸馏后</td>
<td align="center">608</td>
<td align="center">16</td>
<td align="center">106.914</td>
<td align="center">79.0</td>
<td align="center"><a href="https://paddlemodels.bj.bcebos.com/PaddleSlim/yolov3_mobilenetv1_voc_distilled.tar">下载链接</a></td>
</tr>
<tr>
<td align="center">baseline</td>
<td align="center">416</td>
<td align="center">16</td>
<td align="center">-</td>
<td align="center">76.7</td>
<td align="center"><a href="https://paddlemodels.bj.bcebos.com/object_detection/yolov3_mobilenet_v1_voc.tar">下载链接</a></td>
</tr>
<tr>
<td align="center">蒸馏后</td>
<td align="center">416</td>
<td align="center">16</td>
<td align="center">-</td>
<td align="center">78.2</td>
<td align="center"><a href="https://paddlemodels.bj.bcebos.com/PaddleSlim/yolov3_mobilenetv1_voc_distilled.tar">下载链接</a></td>
</tr>
<tr>
<td align="center">baseline</td>
<td align="center">320</td>
<td align="center">16</td>
<td align="center">-</td>
<td align="center">75.3</td>
<td align="center"><a href="https://paddlemodels.bj.bcebos.com/object_detection/yolov3_mobilenet_v1_voc.tar">下载链接</a></td>
</tr>
<tr>
<td align="center">蒸馏后</td>
<td align="center">320</td>
<td align="center">16</td>
<td align="center">-</td>
<td align="center">75.5</td>
<td align="center"><a href="https://paddlemodels.bj.bcebos.com/PaddleSlim/yolov3_mobilenetv1_voc_distilled.tar">下载链接</a></td>
</tr>
</tbody>
</table><blockquote>
<div>蒸馏后的结果用ResNet34-YOLO-V3做teacher,4GPU总batch_size64训练90000 iter得到</div></blockquote>
</div>
<div class="section" id="mobilenetv1-yolo-v3-coco">
<h3>MobileNetV1-YOLO-V3-COCO<a class="headerlink" href="#mobilenetv1-yolo-v3-coco" title="永久链接至标题"></a></h3>
<table border="1" class="docutils">
<thead>
<tr>
<th align="center">FLOPS</th>
<th align="center">输入尺寸</th>
<th align="center">每张GPU图片个数</th>
<th align="center">推理时间(fps)</th>
<th align="center">Box AP</th>
<th align="center">下载</th>
</tr>
</thead>
<tbody>
<tr>
<td align="center">baseline</td>
<td align="center">608</td>
<td align="center">16</td>
<td align="center">78.302</td>
<td align="center">29.3</td>
<td align="center"><a href="https://paddlemodels.bj.bcebos.com/object_detection/yolov3_mobilenet_v1_voc.tar">下载链接</a></td>
</tr>
<tr>
<td align="center">蒸馏后</td>
<td align="center">608</td>
<td align="center">16</td>
<td align="center">78.523</td>
<td align="center">31.4</td>
<td align="center"><a href="https://paddlemodels.bj.bcebos.com/PaddleSlim/yolov3_mobilenetv1_coco_distilled.tar">下载链接</a></td>
</tr>
<tr>
<td align="center">baseline</td>
<td align="center">416</td>
<td align="center">16</td>
<td align="center">-</td>
<td align="center">29.3</td>
<td align="center"><a href="https://paddlemodels.bj.bcebos.com/object_detection/yolov3_mobilenet_v1_voc.tar">下载链接</a></td>
</tr>
<tr>
<td align="center">蒸馏后</td>
<td align="center">416</td>
<td align="center">16</td>
<td align="center">-</td>
<td align="center">30.0</td>
<td align="center"><a href="https://paddlemodels.bj.bcebos.com/PaddleSlim/yolov3_mobilenetv1_coco_distilled.tar">下载链接</a></td>
</tr>
<tr>
<td align="center">baseline</td>
<td align="center">320</td>
<td align="center">16</td>
<td align="center">-</td>
<td align="center">27.0</td>
<td align="center"><a href="https://paddlemodels.bj.bcebos.com/object_detection/yolov3_mobilenet_v1_voc.tar">下载链接</a></td>
</tr>
<tr>
<td align="center">蒸馏后</td>
<td align="center">320</td>
<td align="center">16</td>
<td align="center">-</td>
<td align="center">27.1</td>
<td align="center"><a href="https://paddlemodels.bj.bcebos.com/PaddleSlim/yolov3_mobilenetv1_coco_distilled.tar">下载链接</a></td>
</tr>
</tbody>
</table><blockquote>
<div>蒸馏后的结果用ResNet34-YOLO-V3做teacher,4GPU总batch_size64训练600000 iter得到</div></blockquote>
</div>
</div>
</div>
</div>
</div>
<footer>
<div class="rst-footer-buttons" role="navigation" aria-label="footer navigation">
<a href="paddledetection_slim_nas_tutorial.html" class="btn btn-neutral float-right" title="人脸检测模型小模型结构搜索教程" accesskey="n">Next <span class="fa fa-arrow-circle-right"></span></a>
<a href="darts_nas_turorial.html" class="btn btn-neutral" title="SANAS进阶版实验教程-压缩DARTS产出模型" accesskey="p"><span class="fa fa-arrow-circle-left"></span> Previous</a>
</div>
<hr/>
<div role="contentinfo">
<p>
&copy; Copyright 2020, paddleslim.
</p>
</div>
Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/snide/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>.
</footer>
</div>
</div>
</section>
</div>
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT:'../',
VERSION:'1.0',
COLLAPSE_INDEX:false,
FILE_SUFFIX:'.html',
HAS_SOURCE: true
};
</script>
<script type="text/javascript" src="../_static/jquery.js"></script>
<script type="text/javascript" src="../_static/underscore.js"></script>
<script type="text/javascript" src="../_static/doctools.js"></script>
<script type="text/javascript" src="../_static/translations.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
<script type="text/javascript" src="../_static/js/theme.js"></script>
<script type="text/javascript">
jQuery(function () {
SphinxRtdTheme.StickyNav.enable();
});
</script>
</body>
</html>
\ No newline at end of file
<!DOCTYPE html>
<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]-->
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>人脸检测模型小模型结构搜索教程 &mdash; PaddleSlim 1.0 文档</title>
<link rel="stylesheet" href="../_static/css/theme.css" type="text/css" />
<link rel="index" title="索引"
href="../genindex.html"/>
<link rel="search" title="搜索" href="../search.html"/>
<link rel="top" title="PaddleSlim 1.0 文档" href="../index.html"/>
<link rel="up" title="进阶教程" href="index.html"/>
<link rel="next" title="目标检测模型卷积通道剪裁教程" href="paddledetection_slim_pruing_tutorial.html"/>
<link rel="prev" title="目标检测模型蒸馏教程" href="paddledetection_slim_distillation_tutorial.html"/>
<script src="../_static/js/modernizr.min.js"></script>
</head>
<body class="wy-body-for-nav" role="document">
<div class="wy-grid-for-nav">
<nav data-toggle="wy-nav-shift" class="wy-nav-side">
<div class="wy-side-scroll">
<div class="wy-side-nav-search">
<a href="../index.html" class="icon icon-home"> PaddleSlim
</a>
<div role="search">
<form id="rtd-search-form" class="wy-form" action="../search.html" method="get">
<input type="text" name="q" placeholder="Search docs" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
</div>
</div>
<div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
<ul class="current">
<li class="toctree-l1"><a class="reference internal" href="../index_en.html">English Documents</a></li>
<li class="toctree-l1"><a class="reference internal" href="../intro.html">介绍</a></li>
<li class="toctree-l1"><a class="reference internal" href="../install.html">安装</a></li>
<li class="toctree-l1"><a class="reference internal" href="../quick_start/index.html">快速开始</a></li>
<li class="toctree-l1 current"><a class="reference internal" href="index.html">进阶教程</a><ul class="current">
<li class="toctree-l2"><a class="reference internal" href="image_classification_sensitivity_analysis_tutorial.html">图像分类模型通道剪裁-敏感度分析</a></li>
<li class="toctree-l2"><a class="reference internal" href="darts_nas_turorial.html">SANAS进阶版实验教程-压缩DARTS产出模型</a></li>
<li class="toctree-l2"><a class="reference internal" href="paddledetection_slim_distillation_tutorial.html">目标检测模型蒸馏教程</a></li>
<li class="toctree-l2 current"><a class="current reference internal" href="#">人脸检测模型小模型结构搜索教程</a><ul>
<li class="toctree-l3"><a class="reference internal" href="#id2">概述</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="paddledetection_slim_pruing_tutorial.html">目标检测模型卷积通道剪裁教程</a></li>
<li class="toctree-l2"><a class="reference internal" href="paddledetection_slim_prune_dist_tutorial.html">目标检测模型蒸馏剪裁教程</a></li>
<li class="toctree-l2"><a class="reference internal" href="paddledetection_slim_quantization_tutorial.html">目标检测模型定点量化教程</a></li>
<li class="toctree-l2"><a class="reference internal" href="paddledetection_slim_sensitivy_tutorial.html">目标检测模型敏感度分析教程</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../api_cn/index.html">API文档</a></li>
<li class="toctree-l1"><a class="reference internal" href="../model_zoo.html">模型库</a></li>
<li class="toctree-l1"><a class="reference internal" href="../algo/algo.html">算法原理</a></li>
</ul>
</div>
</div>
</nav>
<section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">
<nav class="wy-nav-top" role="navigation" aria-label="top navigation">
<i data-toggle="wy-nav-top" class="fa fa-bars"></i>
<a href="../index.html">PaddleSlim</a>
</nav>
<div class="wy-nav-content">
<div class="rst-content">
<div role="navigation" aria-label="breadcrumbs navigation">
<ul class="wy-breadcrumbs">
<li><a href="../index.html">Docs</a> &raquo;</li>
<li><a href="index.html">进阶教程</a> &raquo;</li>
<li>人脸检测模型小模型结构搜索教程</li>
<li class="wy-breadcrumbs-aside">
<a href="../_sources/tutorials/paddledetection_slim_nas_tutorial.md.txt" rel="nofollow"> View page source</a>
</li>
</ul>
<hr/>
</div>
<div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
<div itemprop="articleBody">
<div class="section" id="id1">
<h1>人脸检测模型小模型结构搜索教程<a class="headerlink" href="#id1" title="永久链接至标题"></a></h1>
<p>教程内容请参考:<a class="reference external" href="https://github.com/PaddlePaddle/PaddleDetection/blob/release/0.2/slim/nas/README.md">https://github.com/PaddlePaddle/PaddleDetection/blob/release/0.2/slim/nas/README.md</a></p>
<div class="section" id="id2">
<h2>概述<a class="headerlink" href="#id2" title="永久链接至标题"></a></h2>
<p>我们选取人脸检测的BlazeFace模型作为神经网络搜索示例,该示例使用PaddleSlim 辅助完成神经网络搜索实验。
基于PaddleSlim进行搜索实验过程中,搜索限制条件可以选择是浮点运算数(FLOPs)限制还是硬件延时(latency)限制,硬件延时限制需要提供延时表。本示例提供一份基于blazeface搜索空间的硬件延时表,名称是latency_855.txt(基于PaddleLite在骁龙855上测试的延时),可以直接用该表进行blazeface的硬件延时搜索实验。</p>
</div>
</div>
</div>
</div>
<footer>
<div class="rst-footer-buttons" role="navigation" aria-label="footer navigation">
<a href="paddledetection_slim_pruing_tutorial.html" class="btn btn-neutral float-right" title="目标检测模型卷积通道剪裁教程" accesskey="n">Next <span class="fa fa-arrow-circle-right"></span></a>
<a href="paddledetection_slim_distillation_tutorial.html" class="btn btn-neutral" title="目标检测模型蒸馏教程" accesskey="p"><span class="fa fa-arrow-circle-left"></span> Previous</a>
</div>
<hr/>
<div role="contentinfo">
<p>
&copy; Copyright 2020, paddleslim.
</p>
</div>
Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/snide/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>.
</footer>
</div>
</div>
</section>
</div>
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT:'../',
VERSION:'1.0',
COLLAPSE_INDEX:false,
FILE_SUFFIX:'.html',
HAS_SOURCE: true
};
</script>
<script type="text/javascript" src="../_static/jquery.js"></script>
<script type="text/javascript" src="../_static/underscore.js"></script>
<script type="text/javascript" src="../_static/doctools.js"></script>
<script type="text/javascript" src="../_static/translations.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
<script type="text/javascript" src="../_static/js/theme.js"></script>
<script type="text/javascript">
jQuery(function () {
SphinxRtdTheme.StickyNav.enable();
});
</script>
</body>
</html>
\ No newline at end of file
<!DOCTYPE html>
<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]-->
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>目标检测模型卷积通道剪裁教程 &mdash; PaddleSlim 1.0 文档</title>
<link rel="stylesheet" href="../_static/css/theme.css" type="text/css" />
<link rel="index" title="索引"
href="../genindex.html"/>
<link rel="search" title="搜索" href="../search.html"/>
<link rel="top" title="PaddleSlim 1.0 文档" href="../index.html"/>
<link rel="up" title="进阶教程" href="index.html"/>
<link rel="next" title="目标检测模型蒸馏剪裁教程" href="paddledetection_slim_prune_dist_tutorial.html"/>
<link rel="prev" title="人脸检测模型小模型结构搜索教程" href="paddledetection_slim_nas_tutorial.html"/>
<script src="../_static/js/modernizr.min.js"></script>
</head>
<body class="wy-body-for-nav" role="document">
<div class="wy-grid-for-nav">
<nav data-toggle="wy-nav-shift" class="wy-nav-side">
<div class="wy-side-scroll">
<div class="wy-side-nav-search">
<a href="../index.html" class="icon icon-home"> PaddleSlim
</a>
<div role="search">
<form id="rtd-search-form" class="wy-form" action="../search.html" method="get">
<input type="text" name="q" placeholder="Search docs" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
</div>
</div>
<div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
<ul class="current">
<li class="toctree-l1"><a class="reference internal" href="../index_en.html">English Documents</a></li>
<li class="toctree-l1"><a class="reference internal" href="../intro.html">介绍</a></li>
<li class="toctree-l1"><a class="reference internal" href="../install.html">安装</a></li>
<li class="toctree-l1"><a class="reference internal" href="../quick_start/index.html">快速开始</a></li>
<li class="toctree-l1 current"><a class="reference internal" href="index.html">进阶教程</a><ul class="current">
<li class="toctree-l2"><a class="reference internal" href="image_classification_sensitivity_analysis_tutorial.html">图像分类模型通道剪裁-敏感度分析</a></li>
<li class="toctree-l2"><a class="reference internal" href="darts_nas_turorial.html">SANAS进阶版实验教程-压缩DARTS产出模型</a></li>
<li class="toctree-l2"><a class="reference internal" href="paddledetection_slim_distillation_tutorial.html">目标检测模型蒸馏教程</a></li>
<li class="toctree-l2"><a class="reference internal" href="paddledetection_slim_nas_tutorial.html">人脸检测模型小模型结构搜索教程</a></li>
<li class="toctree-l2 current"><a class="current reference internal" href="#">目标检测模型卷积通道剪裁教程</a></li>
<li class="toctree-l2"><a class="reference internal" href="paddledetection_slim_prune_dist_tutorial.html">目标检测模型蒸馏剪裁教程</a></li>
<li class="toctree-l2"><a class="reference internal" href="paddledetection_slim_quantization_tutorial.html">目标检测模型定点量化教程</a></li>
<li class="toctree-l2"><a class="reference internal" href="paddledetection_slim_sensitivy_tutorial.html">目标检测模型敏感度分析教程</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../api_cn/index.html">API文档</a></li>
<li class="toctree-l1"><a class="reference internal" href="../model_zoo.html">模型库</a></li>
<li class="toctree-l1"><a class="reference internal" href="../algo/algo.html">算法原理</a></li>
</ul>
</div>
</div>
</nav>
<section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">
<nav class="wy-nav-top" role="navigation" aria-label="top navigation">
<i data-toggle="wy-nav-top" class="fa fa-bars"></i>
<a href="../index.html">PaddleSlim</a>
</nav>
<div class="wy-nav-content">
<div class="rst-content">
<div role="navigation" aria-label="breadcrumbs navigation">
<ul class="wy-breadcrumbs">
<li><a href="../index.html">Docs</a> &raquo;</li>
<li><a href="index.html">进阶教程</a> &raquo;</li>
<li>目标检测模型卷积通道剪裁教程</li>
<li class="wy-breadcrumbs-aside">
<a href="../_sources/tutorials/paddledetection_slim_pruing_tutorial.md.txt" rel="nofollow"> View page source</a>
</li>
</ul>
<hr/>
</div>
<div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
<div itemprop="articleBody">
<div class="section" id="id1">
<h1>目标检测模型卷积通道剪裁教程<a class="headerlink" href="#id1" title="永久链接至标题"></a></h1>
<p>请参考:<a class="reference external" href="https://github.com/PaddlePaddle/PaddleDetection/blob/release/0.2/slim/prune/README.md">https://github.com/PaddlePaddle/PaddleDetection/blob/release/0.2/slim/prune/README.md</a></p>
</div>
</div>
</div>
<footer>
<div class="rst-footer-buttons" role="navigation" aria-label="footer navigation">
<a href="paddledetection_slim_prune_dist_tutorial.html" class="btn btn-neutral float-right" title="目标检测模型蒸馏剪裁教程" accesskey="n">Next <span class="fa fa-arrow-circle-right"></span></a>
<a href="paddledetection_slim_nas_tutorial.html" class="btn btn-neutral" title="人脸检测模型小模型结构搜索教程" accesskey="p"><span class="fa fa-arrow-circle-left"></span> Previous</a>
</div>
<hr/>
<div role="contentinfo">
<p>
&copy; Copyright 2020, paddleslim.
</p>
</div>
Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/snide/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>.
</footer>
</div>
</div>
</section>
</div>
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT:'../',
VERSION:'1.0',
COLLAPSE_INDEX:false,
FILE_SUFFIX:'.html',
HAS_SOURCE: true
};
</script>
<script type="text/javascript" src="../_static/jquery.js"></script>
<script type="text/javascript" src="../_static/underscore.js"></script>
<script type="text/javascript" src="../_static/doctools.js"></script>
<script type="text/javascript" src="../_static/translations.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
<script type="text/javascript" src="../_static/js/theme.js"></script>
<script type="text/javascript">
jQuery(function () {
SphinxRtdTheme.StickyNav.enable();
});
</script>
</body>
</html>
\ No newline at end of file
<!DOCTYPE html>
<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]-->
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>目标检测模型蒸馏剪裁教程 &mdash; PaddleSlim 1.0 文档</title>
<link rel="stylesheet" href="../_static/css/theme.css" type="text/css" />
<link rel="index" title="索引"
href="../genindex.html"/>
<link rel="search" title="搜索" href="../search.html"/>
<link rel="top" title="PaddleSlim 1.0 文档" href="../index.html"/>
<link rel="up" title="进阶教程" href="index.html"/>
<link rel="next" title="目标检测模型定点量化教程" href="paddledetection_slim_quantization_tutorial.html"/>
<link rel="prev" title="目标检测模型卷积通道剪裁教程" href="paddledetection_slim_pruing_tutorial.html"/>
<script src="../_static/js/modernizr.min.js"></script>
</head>
<body class="wy-body-for-nav" role="document">
<div class="wy-grid-for-nav">
<nav data-toggle="wy-nav-shift" class="wy-nav-side">
<div class="wy-side-scroll">
<div class="wy-side-nav-search">
<a href="../index.html" class="icon icon-home"> PaddleSlim
</a>
<div role="search">
<form id="rtd-search-form" class="wy-form" action="../search.html" method="get">
<input type="text" name="q" placeholder="Search docs" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
</div>
</div>
<div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
<ul class="current">
<li class="toctree-l1"><a class="reference internal" href="../index_en.html">English Documents</a></li>
<li class="toctree-l1"><a class="reference internal" href="../intro.html">介绍</a></li>
<li class="toctree-l1"><a class="reference internal" href="../install.html">安装</a></li>
<li class="toctree-l1"><a class="reference internal" href="../quick_start/index.html">快速开始</a></li>
<li class="toctree-l1 current"><a class="reference internal" href="index.html">进阶教程</a><ul class="current">
<li class="toctree-l2"><a class="reference internal" href="image_classification_sensitivity_analysis_tutorial.html">图像分类模型通道剪裁-敏感度分析</a></li>
<li class="toctree-l2"><a class="reference internal" href="darts_nas_turorial.html">SANAS进阶版实验教程-压缩DARTS产出模型</a></li>
<li class="toctree-l2"><a class="reference internal" href="paddledetection_slim_distillation_tutorial.html">目标检测模型蒸馏教程</a></li>
<li class="toctree-l2"><a class="reference internal" href="paddledetection_slim_nas_tutorial.html">人脸检测模型小模型结构搜索教程</a></li>
<li class="toctree-l2"><a class="reference internal" href="paddledetection_slim_pruing_tutorial.html">目标检测模型卷积通道剪裁教程</a></li>
<li class="toctree-l2 current"><a class="current reference internal" href="#">目标检测模型蒸馏剪裁教程</a><ul>
<li class="toctree-l3"><a class="reference internal" href="#id2">概述</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="paddledetection_slim_quantization_tutorial.html">目标检测模型定点量化教程</a></li>
<li class="toctree-l2"><a class="reference internal" href="paddledetection_slim_sensitivy_tutorial.html">目标检测模型敏感度分析教程</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../api_cn/index.html">API文档</a></li>
<li class="toctree-l1"><a class="reference internal" href="../model_zoo.html">模型库</a></li>
<li class="toctree-l1"><a class="reference internal" href="../algo/algo.html">算法原理</a></li>
</ul>
</div>
</div>
</nav>
<section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">
<nav class="wy-nav-top" role="navigation" aria-label="top navigation">
<i data-toggle="wy-nav-top" class="fa fa-bars"></i>
<a href="../index.html">PaddleSlim</a>
</nav>
<div class="wy-nav-content">
<div class="rst-content">
<div role="navigation" aria-label="breadcrumbs navigation">
<ul class="wy-breadcrumbs">
<li><a href="../index.html">Docs</a> &raquo;</li>
<li><a href="index.html">进阶教程</a> &raquo;</li>
<li>目标检测模型蒸馏剪裁教程</li>
<li class="wy-breadcrumbs-aside">
<a href="../_sources/tutorials/paddledetection_slim_prune_dist_tutorial.md.txt" rel="nofollow"> View page source</a>
</li>
</ul>
<hr/>
</div>
<div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
<div itemprop="articleBody">
<div class="section" id="id1">
<h1>目标检测模型蒸馏剪裁教程<a class="headerlink" href="#id1" title="永久链接至标题"></a></h1>
<p>教程内容请参考:<a class="reference external" href="https://github.com/PaddlePaddle/PaddleDetection/blob/release/0.2/slim/extensions/distill_pruned_model/README.md">https://github.com/PaddlePaddle/PaddleDetection/blob/release/0.2/slim/extensions/distill_pruned_model/README.md</a></p>
<div class="section" id="id2">
<h2>概述<a class="headerlink" href="#id2" title="永久链接至标题"></a></h2>
<p>该文档介绍如何使用PaddleSlim的蒸馏接口和卷积通道剪裁接口对检测库中的模型进行卷积层的通道剪裁并使用较高精度模型对其蒸馏。</p>
</div>
</div>
</div>
</div>
<footer>
<div class="rst-footer-buttons" role="navigation" aria-label="footer navigation">
<a href="paddledetection_slim_quantization_tutorial.html" class="btn btn-neutral float-right" title="目标检测模型定点量化教程" accesskey="n">Next <span class="fa fa-arrow-circle-right"></span></a>
<a href="paddledetection_slim_pruing_tutorial.html" class="btn btn-neutral" title="目标检测模型卷积通道剪裁教程" accesskey="p"><span class="fa fa-arrow-circle-left"></span> Previous</a>
</div>
<hr/>
<div role="contentinfo">
<p>
&copy; Copyright 2020, paddleslim.
</p>
</div>
Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/snide/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>.
</footer>
</div>
</div>
</section>
</div>
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT:'../',
VERSION:'1.0',
COLLAPSE_INDEX:false,
FILE_SUFFIX:'.html',
HAS_SOURCE: true
};
</script>
<script type="text/javascript" src="../_static/jquery.js"></script>
<script type="text/javascript" src="../_static/underscore.js"></script>
<script type="text/javascript" src="../_static/doctools.js"></script>
<script type="text/javascript" src="../_static/translations.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
<script type="text/javascript" src="../_static/js/theme.js"></script>
<script type="text/javascript">
jQuery(function () {
SphinxRtdTheme.StickyNav.enable();
});
</script>
</body>
</html>
\ No newline at end of file
<!DOCTYPE html>
<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]-->
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>目标检测模型定点量化教程 &mdash; PaddleSlim 1.0 文档</title>
<link rel="stylesheet" href="../_static/css/theme.css" type="text/css" />
<link rel="index" title="索引"
href="../genindex.html"/>
<link rel="search" title="搜索" href="../search.html"/>
<link rel="top" title="PaddleSlim 1.0 文档" href="../index.html"/>
<link rel="up" title="进阶教程" href="index.html"/>
<link rel="next" title="目标检测模型敏感度分析教程" href="paddledetection_slim_sensitivy_tutorial.html"/>
<link rel="prev" title="目标检测模型蒸馏剪裁教程" href="paddledetection_slim_prune_dist_tutorial.html"/>
<script src="../_static/js/modernizr.min.js"></script>
</head>
<body class="wy-body-for-nav" role="document">
<div class="wy-grid-for-nav">
<nav data-toggle="wy-nav-shift" class="wy-nav-side">
<div class="wy-side-scroll">
<div class="wy-side-nav-search">
<a href="../index.html" class="icon icon-home"> PaddleSlim
</a>
<div role="search">
<form id="rtd-search-form" class="wy-form" action="../search.html" method="get">
<input type="text" name="q" placeholder="Search docs" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
</div>
</div>
<div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
<ul class="current">
<li class="toctree-l1"><a class="reference internal" href="../index_en.html">English Documents</a></li>
<li class="toctree-l1"><a class="reference internal" href="../intro.html">介绍</a></li>
<li class="toctree-l1"><a class="reference internal" href="../install.html">安装</a></li>
<li class="toctree-l1"><a class="reference internal" href="../quick_start/index.html">快速开始</a></li>
<li class="toctree-l1 current"><a class="reference internal" href="index.html">进阶教程</a><ul class="current">
<li class="toctree-l2"><a class="reference internal" href="image_classification_sensitivity_analysis_tutorial.html">图像分类模型通道剪裁-敏感度分析</a></li>
<li class="toctree-l2"><a class="reference internal" href="darts_nas_turorial.html">SANAS进阶版实验教程-压缩DARTS产出模型</a></li>
<li class="toctree-l2"><a class="reference internal" href="paddledetection_slim_distillation_tutorial.html">目标检测模型蒸馏教程</a></li>
<li class="toctree-l2"><a class="reference internal" href="paddledetection_slim_nas_tutorial.html">人脸检测模型小模型结构搜索教程</a></li>
<li class="toctree-l2"><a class="reference internal" href="paddledetection_slim_pruing_tutorial.html">目标检测模型卷积通道剪裁教程</a></li>
<li class="toctree-l2"><a class="reference internal" href="paddledetection_slim_prune_dist_tutorial.html">目标检测模型蒸馏剪裁教程</a></li>
<li class="toctree-l2 current"><a class="current reference internal" href="#">目标检测模型定点量化教程</a><ul>
<li class="toctree-l3"><a class="reference internal" href="#id2">示例结果</a><ul>
<li class="toctree-l4"><a class="reference internal" href="#id3">训练策略</a></li>
<li class="toctree-l4"><a class="reference internal" href="#yolov3-on-coco">YOLOv3 on COCO</a></li>
</ul>
</li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="paddledetection_slim_sensitivy_tutorial.html">目标检测模型敏感度分析教程</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../api_cn/index.html">API文档</a></li>
<li class="toctree-l1"><a class="reference internal" href="../model_zoo.html">模型库</a></li>
<li class="toctree-l1"><a class="reference internal" href="../algo/algo.html">算法原理</a></li>
</ul>
</div>
</div>
</nav>
<section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">
<nav class="wy-nav-top" role="navigation" aria-label="top navigation">
<i data-toggle="wy-nav-top" class="fa fa-bars"></i>
<a href="../index.html">PaddleSlim</a>
</nav>
<div class="wy-nav-content">
<div class="rst-content">
<div role="navigation" aria-label="breadcrumbs navigation">
<ul class="wy-breadcrumbs">
<li><a href="../index.html">Docs</a> &raquo;</li>
<li><a href="index.html">进阶教程</a> &raquo;</li>
<li>目标检测模型定点量化教程</li>
<li class="wy-breadcrumbs-aside">
<a href="../_sources/tutorials/paddledetection_slim_quantization_tutorial.md.txt" rel="nofollow"> View page source</a>
</li>
</ul>
<hr/>
</div>
<div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
<div itemprop="articleBody">
<div class="section" id="id1">
<h1>目标检测模型定点量化教程<a class="headerlink" href="#id1" title="永久链接至标题"></a></h1>
<p>教程内容请参考:<a class="reference external" href="https://github.com/PaddlePaddle/PaddleDetection/blob/release/0.2/slim/quantization/README.md">https://github.com/PaddlePaddle/PaddleDetection/blob/release/0.2/slim/quantization/README.md</a></p>
<div class="section" id="id2">
<h2>示例结果<a class="headerlink" href="#id2" title="永久链接至标题"></a></h2>
<div class="section" id="id3">
<h3>训练策略<a class="headerlink" href="#id3" title="永久链接至标题"></a></h3>
<ul class="simple">
<li>量化策略<code class="docutils literal"><span class="pre">post</span></code>为使用离线量化得到的模型,<code class="docutils literal"><span class="pre">aware</span></code>为在线量化训练得到的模型。</li>
</ul>
</div>
<div class="section" id="yolov3-on-coco">
<h3>YOLOv3 on COCO<a class="headerlink" href="#yolov3-on-coco" title="永久链接至标题"></a></h3>
<table border="1" class="docutils">
<thead>
<tr>
<th align="left">骨架网络</th>
<th align="center">预训练权重</th>
<th align="center">量化策略</th>
<th align="center">输入尺寸</th>
<th align="center">Box AP</th>
<th align="center">下载</th>
</tr>
</thead>
<tbody>
<tr>
<td align="left">MobileNetV1</td>
<td align="center">ImageNet</td>
<td align="center">post</td>
<td align="center">608</td>
<td align="center">27.9</td>
<td align="center"><a href="https://paddlemodels.bj.bcebos.com/PaddleSlim/yolov3_mobilenetv1_coco_quant_post.tar">下载链接</a></td>
</tr>
<tr>
<td align="left">MobileNetV1</td>
<td align="center">ImageNet</td>
<td align="center">post</td>
<td align="center">416</td>
<td align="center">28.0</td>
<td align="center"><a href="https://paddlemodels.bj.bcebos.com/PaddleSlim/yolov3_mobilenetv1_coco_quant_post.tar">下载链接</a></td>
</tr>
<tr>
<td align="left">MobileNetV1</td>
<td align="center">ImageNet</td>
<td align="center">post</td>
<td align="center">320</td>
<td align="center">26.0</td>
<td align="center"><a href="https://paddlemodels.bj.bcebos.com/PaddleSlim/yolov3_mobilenetv1_coco_quant_post.tar">下载链接</a></td>
</tr>
<tr>
<td align="left">MobileNetV1</td>
<td align="center">ImageNet</td>
<td align="center">aware</td>
<td align="center">608</td>
<td align="center">28.1</td>
<td align="center"><a href="https://paddlemodels.bj.bcebos.com/PaddleSlim/yolov3_mobilenetv1_coco_quant_aware.tar">下载链接</a></td>
</tr>
<tr>
<td align="left">MobileNetV1</td>
<td align="center">ImageNet</td>
<td align="center">aware</td>
<td align="center">416</td>
<td align="center">28.2</td>
<td align="center"><a href="https://paddlemodels.bj.bcebos.com/PaddleSlim/yolov3_mobilenetv1_coco_quant_aware.tar">下载链接</a></td>
</tr>
<tr>
<td align="left">MobileNetV1</td>
<td align="center">ImageNet</td>
<td align="center">aware</td>
<td align="center">320</td>
<td align="center">25.8</td>
<td align="center"><a href="https://paddlemodels.bj.bcebos.com/PaddleSlim/yolov3_mobilenetv1_coco_quant_aware.tar">下载链接</a></td>
</tr>
<tr>
<td align="left">ResNet34</td>
<td align="center">ImageNet</td>
<td align="center">post</td>
<td align="center">608</td>
<td align="center">35.7</td>
<td align="center"><a href="https://paddlemodels.bj.bcebos.com/PaddleSlim/yolov3_r34_coco_quant_post.tar">下载链接</a></td>
</tr>
<tr>
<td align="left">ResNet34</td>
<td align="center">ImageNet</td>
<td align="center">aware</td>
<td align="center">608</td>
<td align="center">35.2</td>
<td align="center"><a href="https://paddlemodels.bj.bcebos.com/PaddleSlim/yolov3_r34_coco_quant_aware.tar">下载链接</a></td>
</tr>
<tr>
<td align="left">ResNet34</td>
<td align="center">ImageNet</td>
<td align="center">aware</td>
<td align="center">416</td>
<td align="center">33.3</td>
<td align="center"><a href="https://paddlemodels.bj.bcebos.com/PaddleSlim/yolov3_r34_coco_quant_aware.tar">下载链接</a></td>
</tr>
<tr>
<td align="left">ResNet34</td>
<td align="center">ImageNet</td>
<td align="center">aware</td>
<td align="center">320</td>
<td align="center">30.3</td>
<td align="center"><a href="https://paddlemodels.bj.bcebos.com/PaddleSlim/yolov3_r34_coco_quant_aware.tar">下载链接</a></td>
</tr>
<tr>
<td align="left">R50vd-dcn</td>
<td align="center">object365</td>
<td align="center">aware</td>
<td align="center">608</td>
<td align="center">40.6</td>
<td align="center"><a href="https://paddlemodels.bj.bcebos.com/PaddleSlim/yolov3_r50vd_dcn_obj365_pretrained_coco_quant_aware.tar">下载链接</a></td>
</tr>
<tr>
<td align="left">R50vd-dcn</td>
<td align="center">object365</td>
<td align="center">aware</td>
<td align="center">416</td>
<td align="center">37.5</td>
<td align="center"><a href="https://paddlemodels.bj.bcebos.com/PaddleSlim/yolov3_r50vd_dcn_obj365_pretrained_coco_quant_aware.tar">下载链接</a></td>
</tr>
<tr>
<td align="left">R50vd-dcn</td>
<td align="center">object365</td>
<td align="center">aware</td>
<td align="center">320</td>
<td align="center">34.1</td>
<td align="center"><a href="https://paddlemodels.bj.bcebos.com/PaddleSlim/yolov3_r50vd_dcn_obj365_pretrained_coco_quant_aware.tar">下载链接</a></td>
</tr>
</tbody>
</table></div>
</div>
</div>
</div>
</div>
<footer>
<div class="rst-footer-buttons" role="navigation" aria-label="footer navigation">
<a href="paddledetection_slim_sensitivy_tutorial.html" class="btn btn-neutral float-right" title="目标检测模型敏感度分析教程" accesskey="n">Next <span class="fa fa-arrow-circle-right"></span></a>
<a href="paddledetection_slim_prune_dist_tutorial.html" class="btn btn-neutral" title="目标检测模型蒸馏剪裁教程" accesskey="p"><span class="fa fa-arrow-circle-left"></span> Previous</a>
</div>
<hr/>
<div role="contentinfo">
<p>
&copy; Copyright 2020, paddleslim.
</p>
</div>
Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/snide/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>.
</footer>
</div>
</div>
</section>
</div>
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT:'../',
VERSION:'1.0',
COLLAPSE_INDEX:false,
FILE_SUFFIX:'.html',
HAS_SOURCE: true
};
</script>
<script type="text/javascript" src="../_static/jquery.js"></script>
<script type="text/javascript" src="../_static/underscore.js"></script>
<script type="text/javascript" src="../_static/doctools.js"></script>
<script type="text/javascript" src="../_static/translations.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
<script type="text/javascript" src="../_static/js/theme.js"></script>
<script type="text/javascript">
jQuery(function () {
SphinxRtdTheme.StickyNav.enable();
});
</script>
</body>
</html>
\ No newline at end of file
<!DOCTYPE html>
<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]-->
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>目标检测模型敏感度分析教程 &mdash; PaddleSlim 1.0 文档</title>
<link rel="stylesheet" href="../_static/css/theme.css" type="text/css" />
<link rel="index" title="索引"
href="../genindex.html"/>
<link rel="search" title="搜索" href="../search.html"/>
<link rel="top" title="PaddleSlim 1.0 文档" href="../index.html"/>
<link rel="up" title="进阶教程" href="index.html"/>
<link rel="next" title="API文档" href="../api_cn/index.html"/>
<link rel="prev" title="目标检测模型定点量化教程" href="paddledetection_slim_quantization_tutorial.html"/>
<script src="../_static/js/modernizr.min.js"></script>
</head>
<body class="wy-body-for-nav" role="document">
<div class="wy-grid-for-nav">
<nav data-toggle="wy-nav-shift" class="wy-nav-side">
<div class="wy-side-scroll">
<div class="wy-side-nav-search">
<a href="../index.html" class="icon icon-home"> PaddleSlim
</a>
<div role="search">
<form id="rtd-search-form" class="wy-form" action="../search.html" method="get">
<input type="text" name="q" placeholder="Search docs" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
</div>
</div>
<div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
<ul class="current">
<li class="toctree-l1"><a class="reference internal" href="../index_en.html">English Documents</a></li>
<li class="toctree-l1"><a class="reference internal" href="../intro.html">介绍</a></li>
<li class="toctree-l1"><a class="reference internal" href="../install.html">安装</a></li>
<li class="toctree-l1"><a class="reference internal" href="../quick_start/index.html">快速开始</a></li>
<li class="toctree-l1 current"><a class="reference internal" href="index.html">进阶教程</a><ul class="current">
<li class="toctree-l2"><a class="reference internal" href="image_classification_sensitivity_analysis_tutorial.html">图像分类模型通道剪裁-敏感度分析</a></li>
<li class="toctree-l2"><a class="reference internal" href="darts_nas_turorial.html">SANAS进阶版实验教程-压缩DARTS产出模型</a></li>
<li class="toctree-l2"><a class="reference internal" href="paddledetection_slim_distillation_tutorial.html">目标检测模型蒸馏教程</a></li>
<li class="toctree-l2"><a class="reference internal" href="paddledetection_slim_nas_tutorial.html">人脸检测模型小模型结构搜索教程</a></li>
<li class="toctree-l2"><a class="reference internal" href="paddledetection_slim_pruing_tutorial.html">目标检测模型卷积通道剪裁教程</a></li>
<li class="toctree-l2"><a class="reference internal" href="paddledetection_slim_prune_dist_tutorial.html">目标检测模型蒸馏剪裁教程</a></li>
<li class="toctree-l2"><a class="reference internal" href="paddledetection_slim_quantization_tutorial.html">目标检测模型定点量化教程</a></li>
<li class="toctree-l2 current"><a class="current reference internal" href="#">目标检测模型敏感度分析教程</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../api_cn/index.html">API文档</a></li>
<li class="toctree-l1"><a class="reference internal" href="../model_zoo.html">模型库</a></li>
<li class="toctree-l1"><a class="reference internal" href="../algo/algo.html">算法原理</a></li>
</ul>
</div>
</div>
</nav>
<section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">
<nav class="wy-nav-top" role="navigation" aria-label="top navigation">
<i data-toggle="wy-nav-top" class="fa fa-bars"></i>
<a href="../index.html">PaddleSlim</a>
</nav>
<div class="wy-nav-content">
<div class="rst-content">
<div role="navigation" aria-label="breadcrumbs navigation">
<ul class="wy-breadcrumbs">
<li><a href="../index.html">Docs</a> &raquo;</li>
<li><a href="index.html">进阶教程</a> &raquo;</li>
<li>目标检测模型敏感度分析教程</li>
<li class="wy-breadcrumbs-aside">
<a href="../_sources/tutorials/paddledetection_slim_sensitivy_tutorial.md.txt" rel="nofollow"> View page source</a>
</li>
</ul>
<hr/>
</div>
<div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
<div itemprop="articleBody">
<div class="section" id="id1">
<h1>目标检测模型敏感度分析教程<a class="headerlink" href="#id1" title="永久链接至标题"></a></h1>
<p>教程内容请参考:<a class="reference external" href="https://github.com/PaddlePaddle/PaddleDetection/blob/release/0.2/slim/sensitive/README.md">https://github.com/PaddlePaddle/PaddleDetection/blob/release/0.2/slim/sensitive/README.md</a></p>
</div>
</div>
</div>
<footer>
<div class="rst-footer-buttons" role="navigation" aria-label="footer navigation">
<a href="../api_cn/index.html" class="btn btn-neutral float-right" title="API文档" accesskey="n">Next <span class="fa fa-arrow-circle-right"></span></a>
<a href="paddledetection_slim_quantization_tutorial.html" class="btn btn-neutral" title="目标检测模型定点量化教程" accesskey="p"><span class="fa fa-arrow-circle-left"></span> Previous</a>
</div>
<hr/>
<div role="contentinfo">
<p>
&copy; Copyright 2020, paddleslim.
</p>
</div>
Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/snide/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>.
</footer>
</div>
</div>
</section>
</div>
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT:'../',
VERSION:'1.0',
COLLAPSE_INDEX:false,
FILE_SUFFIX:'.html',
HAS_SOURCE: true
};
</script>
<script type="text/javascript" src="../_static/jquery.js"></script>
<script type="text/javascript" src="../_static/underscore.js"></script>
<script type="text/javascript" src="../_static/doctools.js"></script>
<script type="text/javascript" src="../_static/translations.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
<script type="text/javascript" src="../_static/js/theme.js"></script>
<script type="text/javascript">
jQuery(function () {
SphinxRtdTheme.StickyNav.enable();
});
</script>
</body>
</html>
\ No newline at end of file
...@@ -80,7 +80,7 @@ ...@@ -80,7 +80,7 @@
<ul> <ul>
<li class="toctree-l1"><a class="reference internal" href="../index_en.html">English Documents</a></li> <li class="toctree-l1"><a class="reference internal" href="../index_en.html">English Documents</a></li>
<li class="toctree-l1"><a class="reference internal" href="../intro.html">PaddleSlim简介</a></li> <li class="toctree-l1"><a class="reference internal" href="../intro.html">介绍</a></li>
<li class="toctree-l1"><a class="reference internal" href="../install.html">安装</a></li> <li class="toctree-l1"><a class="reference internal" href="../install.html">安装</a></li>
<li class="toctree-l1"><a class="reference internal" href="../quick_start/index.html">快速开始</a></li> <li class="toctree-l1"><a class="reference internal" href="../quick_start/index.html">快速开始</a></li>
<li class="toctree-l1"><a class="reference internal" href="index.html">进阶教程</a></li> <li class="toctree-l1"><a class="reference internal" href="index.html">进阶教程</a></li>
...@@ -135,7 +135,7 @@ ...@@ -135,7 +135,7 @@
<h1>图像分类模型通道剪裁-敏感度分析<a class="headerlink" href="#id1" title="永久链接至标题"></a></h1> <h1>图像分类模型通道剪裁-敏感度分析<a class="headerlink" href="#id1" title="永久链接至标题"></a></h1>
<p>该教程以图像分类模型MobileNetV1为例,说明如何快速使用<a class="reference external" href="https://paddlepaddle.github.io/PaddleSlim/api/prune_api/#sensitivity">PaddleSlim的敏感度分析接口</a> <p>该教程以图像分类模型MobileNetV1为例,说明如何快速使用<a class="reference external" href="https://paddlepaddle.github.io/PaddleSlim/api/prune_api/#sensitivity">PaddleSlim的敏感度分析接口</a>
该示例包含以下步骤:</p> 该示例包含以下步骤:</p>
<ol class="simple"> <ol class="arabic simple">
<li>导入依赖</li> <li>导入依赖</li>
<li>构建模型</li> <li>构建模型</li>
<li>定义输入数据</li> <li>定义输入数据</li>
...@@ -149,9 +149,9 @@ ...@@ -149,9 +149,9 @@
<div class="section" id="id2"> <div class="section" id="id2">
<h2>1. 导入依赖<a class="headerlink" href="#id2" title="永久链接至标题"></a></h2> <h2>1. 导入依赖<a class="headerlink" href="#id2" title="永久链接至标题"></a></h2>
<p>PaddleSlim依赖Paddle1.7版本,请确认已正确安装Paddle,然后按以下方式导入Paddle和PaddleSlim:</p> <p>PaddleSlim依赖Paddle1.7版本,请确认已正确安装Paddle,然后按以下方式导入Paddle和PaddleSlim:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">paddle</span> <div class="highlight-guess"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">paddle</span>
<span class="kn">import</span> <span class="nn">paddle.fluid</span> <span class="k">as</span> <span class="nn">fluid</span> <span class="kn">import</span> <span class="nn">paddle.fluid</span> <span class="kn">as</span> <span class="nn">fluid</span>
<span class="kn">import</span> <span class="nn">paddleslim</span> <span class="k">as</span> <span class="nn">slim</span> <span class="kn">import</span> <span class="nn">paddleslim</span> <span class="kn">as</span> <span class="nn">slim</span>
</pre></div> </pre></div>
</div> </div>
</div> </div>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册