index.html 14.6 KB
Newer Older
1
<!DOCTYPE html>
2 3 4 5 6 7 8 9 10
<!--[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 http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta name="description" content="None">
  
  <link rel="shortcut icon" href="img/favicon.ico">
11
  <title>Home - PaddleSlim Docs</title>
12
  <link href='https://fonts.googleapis.com/css?family=Lato:400,700|Roboto+Slab:400,700|Inconsolata:400,700' rel='stylesheet' type='text/css'>
13

14 15 16 17 18 19
  <link rel="stylesheet" href="css/theme.css" type="text/css" />
  <link rel="stylesheet" href="css/theme_extra.css" type="text/css" />
  <link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/styles/github.min.css">
  
  <script>
    // Current page data
20
    var mkdocs_page_name = "Home";
21 22 23 24 25 26 27 28 29 30
    var mkdocs_page_input_path = "index.md";
    var mkdocs_page_url = null;
  </script>
  
  <script src="js/jquery-2.1.1.min.js" defer></script>
  <script src="js/modernizr-2.8.3.min.js" defer></script>
  <script src="//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/highlight.min.js"></script>
  <script>hljs.initHighlightingOnLoad();</script> 
  
</head>
31

32
<body class="wy-body-for-nav" role="document">
33

34
  <div class="wy-grid-for-nav">
35

36 37 38
    
    <nav data-toggle="wy-nav-shift" class="wy-nav-side stickynav">
      <div class="wy-side-nav-search">
39
        <a href="." class="icon icon-home"> PaddleSlim Docs</a>
40 41 42 43 44 45
        <div role="search">
  <form id ="rtd-search-form" class="wy-form" action="./search.html" method="get">
    <input type="text" name="q" placeholder="Search docs" title="Type search term here" />
  </form>
</div>
      </div>
46

47 48 49 50 51 52
      <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
	<ul class="current">
	  
          
            <li class="toctree-l1 current">
		
53
    <a class="current" href=".">Home</a>
54
    <ul class="subnav">
55
            
56
    <li class="toctree-l2"><a href="#paddleslim">PaddleSlim</a></li>
57 58 59
    
        <ul>
        
60
            <li><a class="toctree-l3" href="#_1">架构</a></li>
61
        
62
            <li><a class="toctree-l3" href="#_2">功能</a></li>
63
        
64
            <li><a class="toctree-l3" href="#_3">安装</a></li>
65
        
66 67 68
            <li><a class="toctree-l3" href="#_4">性能</a></li>
        
            <li><a class="toctree-l3" href="#_8">最佳实践</a></li>
69 70 71 72
        
        </ul>
    

73
    </ul>
74 75 76 77
	    </li>
          
            <li class="toctree-l1">
		
78 79 80 81 82
    <a class="" href="model_zoo/">模型库</a>
	    </li>
          
            <li class="toctree-l1">
		
83
    <span class="caption-text">教程</span>
84 85 86
    <ul class="subnav">
                <li class="">
                    
87
    <a class="" href="tutorials/quant_post_demo/">离线量化</a>
88
                </li>
89
                <li class="">
90
                    
91
    <a class="" href="tutorials/quant_aware_demo/">量化训练</a>
92
                </li>
93 94
                <li class="">
                    
95
    <a class="" href="tutorials/quant_embedding_demo/">Embedding量化</a>
96
                </li>
97
                <li class="">
98
                    
99
    <a class="" href="tutorials/nas_demo/">SA搜索</a>
100
                </li>
101
                <li class="">
102
                    
103
    <a class="" href="tutorials/distillation_demo/">知识蒸馏</a>
104
                </li>
105 106 107 108 109
    </ul>
	    </li>
          
            <li class="toctree-l1">
		
110
    <span class="caption-text">API</span>
111
    <ul class="subnav">
112
                <li class="">
113
                    
114
    <a class="" href="api/quantization_api/">量化</a>
115
                </li>
116
                <li class="">
117
                    
118
    <a class="" href="api/prune_api/">剪枝与敏感度</a>
119
                </li>
120
                <li class="">
121
                    
122
    <a class="" href="api/analysis_api/">模型分析</a>
123
                </li>
124 125
                <li class="">
                    
126
    <a class="" href="api/single_distiller_api/">知识蒸馏</a>
127
                </li>
128 129
                <li class="">
                    
130 131 132 133 134 135 136 137 138
    <a class="" href="api/nas_api/">SA搜索</a>
                </li>
                <li class="">
                    
    <a class="" href="api/search_space/">搜索空间</a>
                </li>
                <li class="">
                    
    <a class="" href="table_latency/">硬件延时评估表</a>
139
                </li>
140
    </ul>
141 142
	    </li>
          
143 144 145 146 147
            <li class="toctree-l1">
		
    <a class="" href="algo/algo/">算法原理</a>
	    </li>
          
148 149 150 151
        </ul>
      </div>
      &nbsp;
    </nav>
152

153
    <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">
154

155 156 157
      
      <nav class="wy-nav-top" role="navigation" aria-label="top navigation">
        <i data-toggle="wy-nav-top" class="fa fa-bars"></i>
158
        <a href=".">PaddleSlim Docs</a>
159
      </nav>
160

161 162 163 164 165 166 167 168 169
      
      <div class="wy-nav-content">
        <div class="rst-content">
          <div role="navigation" aria-label="breadcrumbs navigation">
  <ul class="wy-breadcrumbs">
    <li><a href=".">Docs</a> &raquo;</li>
    
      
    
170
    <li>Home</li>
171 172
    <li class="wy-breadcrumbs-aside">
      
173 174 175
        <a href="https://github.com/PaddlePaddle/PaddleSlim/edit/master/docs/index.md"
          class="icon icon-github"> Edit on GitHub</a>
      
176 177 178 179 180 181 182
    </li>
  </ul>
  <hr/>
</div>
          <div role="main">
            <div class="section">
              
183
                <h1 id="paddleslim">PaddleSlim<a class="headerlink" href="#paddleslim" title="Permanent link">#</a></h1>
184
<p><a href="https://github.com/PaddlePaddle/PaddleSlim">PaddleSlim</a>是PaddlePaddle框架的一个子模块,主要用于压缩图像领域模型。在PaddleSlim中,不仅实现了目前主流的网络剪枝、量化、蒸馏三种压缩策略,还实现了超参数搜索和小模型网络结构搜索功能。在后续版本中,会添加更多的压缩策略,以及完善对NLP领域模型的支持。</p>
185 186 187
<h2 id="_1">架构<a class="headerlink" href="#_1" title="Permanent link">#</a></h2>
<p>(TODO) PaddleSlim架构介绍...</p>
<h2 id="_2">功能<a class="headerlink" href="#_2" title="Permanent link">#</a></h2>
188
<ul>
189
<li>
190 191 192 193 194 195
<p>模型剪裁</p>
<ul>
<li>通道均匀模型剪裁</li>
<li>基于敏感度的模型剪裁</li>
<li>基于进化算法的自动模型剪裁</li>
</ul>
196 197 198
</li>
<li>
<p>量化训练</p>
199 200 201 202 203
<ul>
<li>在线量化训练</li>
<li>离线量化</li>
<li>对权重全局量化和Channel-Wise量化</li>
</ul>
204 205
</li>
<li>
206
<p>知识蒸馏</p>
207 208 209
</li>
<li>
<p>轻量神经网络结构自动搜索(Light-NAS)</p>
210
<ul>
211
<li>基于进化算法的轻量神经网络结构自动搜索</li>
212
<li>支持FLOPS / 硬件延时约束</li>
213 214
<li>支持多平台模型延时评估</li>
</ul>
215 216 217
</li>
</ul>
<h2 id="_3">安装<a class="headerlink" href="#_3" title="Permanent link">#</a></h2>
218 219 220 221
<p>安装PaddleSlim前,请确认已正确安装Paddle1.6版本或更新版本。Paddle安装请参考:<a href="https://www.paddlepaddle.org.cn/install/quick">Paddle安装教程</a></p>
<ul>
<li>安装develop版本</li>
</ul>
222 223 224
<table class="codehilitetable"><tr><td class="linenos"><div class="linenodiv"><pre><span></span>1
2
3</pre></div></td><td class="code"><div class="codehilite"><pre><span></span><span class="n">git</span> <span class="n">clone</span> <span class="n">https</span><span class="p">:</span><span class="o">//</span><span class="n">github</span><span class="p">.</span><span class="n">com</span><span class="o">/</span><span class="n">PaddlePaddle</span><span class="o">/</span><span class="n">PaddleSlim</span><span class="p">.</span><span class="n">git</span>
225 226 227
<span class="n">cd</span> <span class="n">PaddleSlim</span>
<span class="n">python</span> <span class="n">setup</span><span class="p">.</span><span class="n">py</span> <span class="n">install</span>
</pre></div>
228
</td></tr></table>
229 230 231 232

<ul>
<li>安装官方发布的最新版本</li>
</ul>
233
<table class="codehilitetable"><tr><td class="linenos"><div class="linenodiv"><pre><span></span>1</pre></div></td><td class="code"><div class="codehilite"><pre><span></span><span class="n">pip</span> <span class="n">install</span> <span class="n">paddleslim</span> <span class="o">-</span><span class="n">i</span> <span class="n">https</span><span class="p">:</span><span class="o">//</span><span class="n">pypi</span><span class="p">.</span><span class="n">org</span><span class="o">/</span><span class="k">simple</span>
234
</pre></div>
235
</td></tr></table>
236 237 238 239 240

<ul>
<li>安装历史版本</li>
</ul>
<p>请点击<a href="https://pypi.org/project/paddleslim/#history">pypi.org</a>查看可安装历史版本。</p>
241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383
<h2 id="_4">性能<a class="headerlink" href="#_4" title="Permanent link">#</a></h2>
<p>PaddleSlim的离线量化、在线量化、均匀剪裁、敏感度剪裁、知识蒸馏等策略在多个主流CNN模型上都进行了验证,部分实验结果如下,全部的实验结果请参见<a href="">模型库</a></p>
<h4 id="_5">量化<a class="headerlink" href="#_5" title="Permanent link">#</a></h4>
<p>我们在多个模型上分别验证了离线量化和在线量化的效果:离线量化过程简单,无需再次训练,但精度损失相对较多;在线量化需要额外的训练过程,但好处是精度损失可以被有效降低:</p>
<table>
<thead>
<tr>
<th align="center">模型</th>
<th align="center">压缩方法</th>
<th align="center">Top-1/Top-5 Acc</th>
<th align="center">模型大小(MB)</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">xx</td>
</tr>
<tr>
<td align="center">MobileNetV2</td>
<td align="center">quant_post</td>
<td align="center">xx%/xx%</td>
<td align="center">xx</td>
</tr>
<tr>
<td align="center">MobileNetV2</td>
<td align="center">quant_aware</td>
<td align="center">xx%/xx%</td>
<td align="center">xx</td>
</tr>
<tr>
<td align="center">ResNet50</td>
<td align="center">-</td>
<td align="center">76.50%/93.00%</td>
<td align="center">xx</td>
</tr>
<tr>
<td align="center">ResNet50</td>
<td align="center">quant_post</td>
<td align="center">xx%/xx%</td>
<td align="center">xx</td>
</tr>
<tr>
<td align="center">ResNet50</td>
<td align="center">quant_aware</td>
<td align="center">xx%/xx%</td>
<td align="center">xx</td>
</tr>
</tbody>
</table>
<h4 id="_6">剪裁<a class="headerlink" href="#_6" title="Permanent link">#</a></h4>
<p>模型剪裁在不带来过多精度损失的前提下有效降低模型计算的FLOPs(floating point operations per second),PaddleSlim在多个模型上验证了均匀剪裁、敏感度剪裁、自动剪裁三种方式,并取得了一定收益:</p>
<table>
<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">FLOPs(M)</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">xx</td>
<td align="center">xx</td>
</tr>
<tr>
<td align="center">MobileNetV2</td>
<td align="center">uniform -xx%</td>
<td align="center">xx%/xx%</td>
<td align="center">xx</td>
<td align="center">xx</td>
</tr>
<tr>
<td align="center">MobileNetV2</td>
<td align="center">sensitive -xx%</td>
<td align="center">xx%/xx%</td>
<td align="center">xx</td>
<td align="center">xx</td>
</tr>
<tr>
<td align="center">ResNet34</td>
<td align="center">-</td>
<td align="center">74.57%/92.14%</td>
<td align="center">xx</td>
<td align="center">xx</td>
</tr>
<tr>
<td align="center">ResNet34</td>
<td align="center">uniform -xx%</td>
<td align="center">xx%/xx%</td>
<td align="center">xx</td>
<td align="center">xx</td>
</tr>
<tr>
<td align="center">ResNet34</td>
<td align="center">auto -xx%</td>
<td align="center">xx%/xx%</td>
<td align="center">xx</td>
<td align="center">xx</td>
</tr>
</tbody>
</table>
<h4 id="_7">蒸馏<a class="headerlink" href="#_7" title="Permanent link">#</a></h4>
<p>我们在多个图象分类和目标检测模型上应用了PaddleSlim的知识蒸馏功能,这些实验在不增加目标模型计算复杂度的前提下都一定程度提升了其精度表现:</p>
<table>
<thead>
<tr>
<th align="center">模型</th>
<th align="center">压缩方法</th>
<th align="center">Top-1/Top-5 Acc</th>
</tr>
</thead>
<tbody>
<tr>
<td align="center">MobileNetV2</td>
<td align="center">-</td>
<td align="center">72.15%/90.65%</td>
</tr>
<tr>
<td align="center">MobileNetV2</td>
<td align="center">ResNet50_vd distill</td>
<td align="center">74.28%/91.53%</td>
</tr>
<tr>
<td align="center">ResNet50</td>
<td align="center">-</td>
<td align="center">76.50%/93.00%</td>
</tr>
<tr>
<td align="center">ResNet50</td>
<td align="center">ResNet101 distill</td>
<td align="center">77.29%/93.65%</td>
</tr>
</tbody>
</table>
<h2 id="_8">最佳实践<a class="headerlink" href="#_8" title="Permanent link">#</a></h2>
384
<ul>
385 386
<li><a href="">Paddle检测库</a>:介绍如何在PaddleDetection检测库中使用PaddleSlim。</li>
<li><a href="">Paddle分割库</a>:介绍如何在PaddleSeg分割库中使用PaddleSlim。</li>
387 388
<li><a href="">PaddleLite</a>:介绍如何使用预测库PaddleLite部署PaddleSlim产出的模型。</li>
</ul>
389
              
390
            </div>
391 392 393 394 395
          </div>
          <footer>
  
    <div class="rst-footer-buttons" role="navigation" aria-label="footer navigation">
      
396
        <a href="model_zoo/" class="btn btn-neutral float-right" title="模型库">Next <span class="icon icon-circle-arrow-right"></span></a>
397 398
      
      
399
    </div>
400 401 402 403 404 405 406 407 408 409 410 411
  

  <hr/>

  <div role="contentinfo">
    <!-- Copyright etc -->
    
  </div>

  Built with <a href="http://www.mkdocs.org">MkDocs</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>
      
412
        </div>
413 414 415 416 417 418 419 420 421
      </div>

    </section>

  </div>

  <div class="rst-versions" role="note" style="cursor: pointer">
    <span class="rst-current-version" data-toggle="rst-current-version">
      
422 423
          <a href="https://github.com/PaddlePaddle/PaddleSlim/" class="fa fa-github" style="float: left; color: #fcfcfc"> GitHub</a>
      
424 425
      
      
426
        <span style="margin-left: 15px"><a href="model_zoo/" style="color: #fcfcfc">Next &raquo;</a></span>
427 428
      
    </span>
429
</div>
430 431
    <script>var base_url = '.';</script>
    <script src="js/theme.js" defer></script>
432
      <script src="mathjax-config.js" defer></script>
433
      <script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js?config=TeX-AMS-MML_HTMLorMML" defer></script>
434
      <script src="search/main.js" defer></script>
435

436
</body>
437 438 439 440
</html>

<!--
MkDocs version : 1.0.4
441
Build Date UTC : 2020-01-08 09:50:23
442
-->