提交 8a62b6fe 编写于 作者: B baiyfbupt

Deployed ab60054 with MkDocs version: 1.0.4

上级 fc74b36d
...@@ -104,7 +104,7 @@ ...@@ -104,7 +104,7 @@
</li> </li>
<li class=""> <li class="">
<a class="" href="/api/search_space/">搜索空间</a> <a class="" href="/api/search_space.md">搜索空间</a>
</li> </li>
<li class=""> <li class="">
......
...@@ -111,7 +111,7 @@ ...@@ -111,7 +111,7 @@
</li> </li>
<li class=""> <li class="">
<a class="" href="../../api/search_space/">搜索空间</a> <a class="" href="../../api/search_space.md">搜索空间</a>
</li> </li>
<li class=""> <li class="">
......
...@@ -123,7 +123,7 @@ ...@@ -123,7 +123,7 @@
</li> </li>
<li class=""> <li class="">
<a class="" href="../search_space/">搜索空间</a> <a class="" href="../search_space.md">搜索空间</a>
</li> </li>
<li class=""> <li class="">
...@@ -178,7 +178,7 @@ ...@@ -178,7 +178,7 @@
<h2 id="flops">FLOPs<a class="headerlink" href="#flops" title="Permanent link">#</a></h2> <h2 id="flops">FLOPs<a class="headerlink" href="#flops" title="Permanent link">#</a></h2>
<dl> <dl>
<dt>paddleslim.analysis.flops(program, detail=False) <a href="https://github.com/PaddlePaddle/PaddleSlim/blob/develop/paddleslim/analysis/flops.py">源代码</a></dt> <dt>paddleslim.analysis.flops(program, detail=False) <a href="https://github.com/PaddlePaddle/PaddleSlim/blob/develop/paddleslim/analysis/flops.py">[源代码]</a></dt>
<dd> <dd>
<p>获得指定网络的浮点运算次数(FLOPs)。</p> <p>获得指定网络的浮点运算次数(FLOPs)。</p>
</dd> </dd>
...@@ -314,8 +314,12 @@ ...@@ -314,8 +314,12 @@
</td></tr></table> </td></tr></table>
<h2 id="model_size">model_size<a class="headerlink" href="#model_size" title="Permanent link">#</a></h2> <h2 id="model_size">model_size<a class="headerlink" href="#model_size" title="Permanent link">#</a></h2>
<p>paddleslim.analysis.model_size(program) <a href="https://github.com/PaddlePaddle/PaddleSlim/blob/develop/paddleslim/analysis/model_size.py">源代码</a></p> <dl>
<dt>paddleslim.analysis.model_size(program) <a href="https://github.com/PaddlePaddle/PaddleSlim/blob/develop/paddleslim/analysis/model_size.py">[源代码]</a></dt>
<dd>
<p>获得指定网络的参数数量。</p> <p>获得指定网络的参数数量。</p>
</dd>
</dl>
<p><strong>参数:</strong></p> <p><strong>参数:</strong></p>
<ul> <ul>
<li><strong>program(paddle.fluid.Program)</strong> - 待分析的目标网络。更多关于Program的介绍请参考:<a href="https://www.paddlepaddle.org.cn/documentation/docs/zh/api_cn/fluid_cn/Program_cn.html#program">Program概念介绍</a></li> <li><strong>program(paddle.fluid.Program)</strong> - 待分析的目标网络。更多关于Program的介绍请参考:<a href="https://www.paddlepaddle.org.cn/documentation/docs/zh/api_cn/fluid_cn/Program_cn.html#program">Program概念介绍</a></li>
...@@ -419,7 +423,7 @@ ...@@ -419,7 +423,7 @@
<h2 id="tablelatencyevaluator">TableLatencyEvaluator<a class="headerlink" href="#tablelatencyevaluator" title="Permanent link">#</a></h2> <h2 id="tablelatencyevaluator">TableLatencyEvaluator<a class="headerlink" href="#tablelatencyevaluator" title="Permanent link">#</a></h2>
<dl> <dl>
<dt>paddleslim.analysis.TableLatencyEvaluator(table_file, delimiter=",") <a href="https://github.com/PaddlePaddle/PaddleSlim/blob/develop/paddleslim/analysis/latency.py">源代码</a></dt> <dt>paddleslim.analysis.TableLatencyEvaluator(table_file, delimiter=",") <a href="https://github.com/PaddlePaddle/PaddleSlim/blob/develop/paddleslim/analysis/latency.py">[源代码]</a></dt>
<dd> <dd>
<p>基于硬件延时表的模型延时评估器。</p> <p>基于硬件延时表的模型延时评估器。</p>
</dd> </dd>
...@@ -427,7 +431,7 @@ ...@@ -427,7 +431,7 @@
<p><strong>参数:</strong></p> <p><strong>参数:</strong></p>
<ul> <ul>
<li> <li>
<p><strong>table_file(str)</strong> - 所使用的延时评估表的绝对路径。关于演示评估表格式请参考:<a href="../paddleslim/analysis/table_latency.md">PaddleSlim硬件延时评估表格式</a></p> <p><strong>table_file(str)</strong> - 所使用的延时评估表的绝对路径。关于演示评估表格式请参考:<a href="https://github.com/PaddlePaddle/PaddleSlim/blob/develop/docs/docs/table_latency.md">PaddleSlim硬件延时评估表格式</a></p>
</li> </li>
<li> <li>
<p><strong>delimiter(str)</strong> - 硬件延时评估表中,操作信息之前所使用的分割符,默认为英文字符逗号。</p> <p><strong>delimiter(str)</strong> - 硬件延时评估表中,操作信息之前所使用的分割符,默认为英文字符逗号。</p>
...@@ -438,7 +442,7 @@ ...@@ -438,7 +442,7 @@
<li><strong>Evaluator</strong> - 硬件延时评估器的实例。</li> <li><strong>Evaluator</strong> - 硬件延时评估器的实例。</li>
</ul> </ul>
<dl> <dl>
<dt>paddleslim.analysis.TableLatencyEvaluator.latency(graph) <a href="https://github.com/PaddlePaddle/PaddleSlim/blob/develop/paddleslim/analysis/latency.py">源代码</a></dt> <dt>paddleslim.analysis.TableLatencyEvaluator.latency(graph) <a href="https://github.com/PaddlePaddle/PaddleSlim/blob/develop/paddleslim/analysis/latency.py">[源代码]</a></dt>
<dd> <dd>
<p>获得指定网络的预估延时。</p> <p>获得指定网络的预估延时。</p>
</dd> </dd>
......
...@@ -111,7 +111,7 @@ ...@@ -111,7 +111,7 @@
</li> </li>
<li class=""> <li class="">
<a class="" href="../search_space/">搜索空间</a> <a class="" href="../search_space.md">搜索空间</a>
</li> </li>
<li class=""> <li class="">
...@@ -187,7 +187,7 @@ ...@@ -187,7 +187,7 @@
<h2 id="_5"><a href="">小模型结构搜索</a><a class="headerlink" href="#_5" title="Permanent link">#</a></h2> <h2 id="_5"><a href="">小模型结构搜索</a><a class="headerlink" href="#_5" title="Permanent link">#</a></h2>
<ul> <ul>
<li><a href="../nas_api/">nas API</a></li> <li><a href="../nas_api/">nas API</a></li>
<li><a href="../search_space/">SearchSpace</a></li> <li><a href="./search_space.md">SearchSpace</a></li>
</ul> </ul>
</div> </div>
......
此差异已折叠。
...@@ -129,7 +129,7 @@ ...@@ -129,7 +129,7 @@
</li> </li>
<li class=""> <li class="">
<a class="" href="../search_space/">搜索空间</a> <a class="" href="../search_space.md">搜索空间</a>
</li> </li>
<li class=""> <li class="">
...@@ -184,7 +184,7 @@ ...@@ -184,7 +184,7 @@
<h2 id="pruner">Pruner<a class="headerlink" href="#pruner" title="Permanent link">#</a></h2> <h2 id="pruner">Pruner<a class="headerlink" href="#pruner" title="Permanent link">#</a></h2>
<dl> <dl>
<dt>paddleslim.prune.Pruner(criterion="l1_norm")<a href="https://github.com/PaddlePaddle/PaddleSlim/blob/develop/paddleslim/prune/pruner.py#L28">源代码</a></dt> <dt>paddleslim.prune.Pruner(criterion="l1_norm")<a href="https://github.com/PaddlePaddle/PaddleSlim/blob/develop/paddleslim/prune/pruner.py#L28">[源代码]</a></dt>
<dd> <dd>
<p>对卷积网络的通道进行一次剪裁。剪裁一个卷积层的通道,是指剪裁该卷积层输出的通道。卷积层的权重形状为<code>[output_channel, input_channel, kernel_size, kernel_size]</code>,通过剪裁该权重的第一纬度达到剪裁输出通道数的目的。</p> <p>对卷积网络的通道进行一次剪裁。剪裁一个卷积层的通道,是指剪裁该卷积层输出的通道。卷积层的权重形状为<code>[output_channel, input_channel, kernel_size, kernel_size]</code>,通过剪裁该权重的第一纬度达到剪裁输出通道数的目的。</p>
</dd> </dd>
...@@ -202,7 +202,7 @@ ...@@ -202,7 +202,7 @@
</td></tr></table> </td></tr></table>
<dl> <dl>
<dt>paddleslim.prune.Pruner.prune(program, scope, params, ratios, place=None, lazy=False, only_graph=False, param_backup=False, param_shape_backup=False)<a href="https://github.com/PaddlePaddle/PaddleSlim/blob/develop/paddleslim/prune/pruner.py#L36">源代码</a></dt> <dt>paddleslim.prune.Pruner.prune(program, scope, params, ratios, place=None, lazy=False, only_graph=False, param_backup=False, param_shape_backup=False)<a href="https://github.com/PaddlePaddle/PaddleSlim/blob/develop/paddleslim/prune/pruner.py#L36">[源代码]</a></dt>
<dd> <dd>
<p>对目标网络的一组卷积层的权重进行裁剪。</p> <p>对目标网络的一组卷积层的权重进行裁剪。</p>
</dd> </dd>
...@@ -404,7 +404,7 @@ ...@@ -404,7 +404,7 @@
<hr /> <hr />
<h2 id="sensitivity">sensitivity<a class="headerlink" href="#sensitivity" title="Permanent link">#</a></h2> <h2 id="sensitivity">sensitivity<a class="headerlink" href="#sensitivity" title="Permanent link">#</a></h2>
<dl> <dl>
<dt>paddleslim.prune.sensitivity(program, place, param_names, eval_func, sensitivities_file=None, pruned_ratios=None) <a href="https://github.com/PaddlePaddle/PaddleSlim/blob/develop/paddleslim/prune/sensitive.py#L34">源代码</a></dt> <dt>paddleslim.prune.sensitivity(program, place, param_names, eval_func, sensitivities_file=None, pruned_ratios=None) <a href="https://github.com/PaddlePaddle/PaddleSlim/blob/develop/paddleslim/prune/sensitive.py#L34">[源代码]</a></dt>
<dd> <dd>
<p>计算网络中每个卷积层的敏感度。每个卷积层的敏感度信息统计方法为:依次剪掉当前卷积层不同比例的输出通道数,在测试集上计算剪裁后的精度损失。得到敏感度信息后,可以通过观察或其它方式确定每层卷积的剪裁率。</p> <p>计算网络中每个卷积层的敏感度。每个卷积层的敏感度信息统计方法为:依次剪掉当前卷积层不同比例的输出通道数,在测试集上计算剪裁后的精度损失。得到敏感度信息后,可以通过观察或其它方式确定每层卷积的剪裁率。</p>
</dd> </dd>
...@@ -653,7 +653,7 @@ ...@@ -653,7 +653,7 @@
<h2 id="merge_sensitive">merge_sensitive<a class="headerlink" href="#merge_sensitive" title="Permanent link">#</a></h2> <h2 id="merge_sensitive">merge_sensitive<a class="headerlink" href="#merge_sensitive" title="Permanent link">#</a></h2>
<dl> <dl>
<dt>paddleslim.prune.merge_sensitive(sensitivities)<a href="https://github.com/PaddlePaddle/PaddleSlim/blob/develop/paddleslim/prune/sensitive.py#L161">源代码</a></dt> <dt>paddleslim.prune.merge_sensitive(sensitivities)<a href="https://github.com/PaddlePaddle/PaddleSlim/blob/develop/paddleslim/prune/sensitive.py#L161">[源代码]</a></dt>
<dd> <dd>
<p>合并多个敏感度信息。</p> <p>合并多个敏感度信息。</p>
</dd> </dd>
...@@ -690,7 +690,7 @@ ...@@ -690,7 +690,7 @@
<p>示例:</p> <p>示例:</p>
<h2 id="load_sensitivities">load_sensitivities<a class="headerlink" href="#load_sensitivities" title="Permanent link">#</a></h2> <h2 id="load_sensitivities">load_sensitivities<a class="headerlink" href="#load_sensitivities" title="Permanent link">#</a></h2>
<dl> <dl>
<dt>paddleslim.prune.load_sensitivities(sensitivities_file)<a href="https://github.com/PaddlePaddle/PaddleSlim/blob/develop/paddleslim/prune/sensitive.py#L184">源代码</a></dt> <dt>paddleslim.prune.load_sensitivities(sensitivities_file)<a href="https://github.com/PaddlePaddle/PaddleSlim/blob/develop/paddleslim/prune/sensitive.py#L184">[源代码]</a></dt>
<dd> <dd>
<p>从文件中加载敏感度信息。</p> <p>从文件中加载敏感度信息。</p>
</dd> </dd>
...@@ -706,7 +706,7 @@ ...@@ -706,7 +706,7 @@
<p>示例:</p> <p>示例:</p>
<h2 id="get_ratios_by_loss">get_ratios_by_loss<a class="headerlink" href="#get_ratios_by_loss" title="Permanent link">#</a></h2> <h2 id="get_ratios_by_loss">get_ratios_by_loss<a class="headerlink" href="#get_ratios_by_loss" title="Permanent link">#</a></h2>
<dl> <dl>
<dt>paddleslim.prune.get_ratios_by_loss(sensitivities, loss)<a href="https://github.com/PaddlePaddle/PaddleSlim/blob/develop/paddleslim/prune/sensitive.py#L206">源代码</a></dt> <dt>paddleslim.prune.get_ratios_by_loss(sensitivities, loss)<a href="https://github.com/PaddlePaddle/PaddleSlim/blob/develop/paddleslim/prune/sensitive.py#L206">[源代码]</a></dt>
<dd> <dd>
<p>根据敏感度和精度损失阈值计算出一组剪切率。对于参数<code>w</code>, 其剪裁率为使精度损失低于<code>loss</code>的最大剪裁率。</p> <p>根据敏感度和精度损失阈值计算出一组剪切率。对于参数<code>w</code>, 其剪裁率为使精度损失低于<code>loss</code>的最大剪裁率。</p>
</dd> </dd>
......
...@@ -129,7 +129,7 @@ ...@@ -129,7 +129,7 @@
</li> </li>
<li class=""> <li class="">
<a class="" href="../search_space/">搜索空间</a> <a class="" href="../search_space.md">搜索空间</a>
</li> </li>
<li class=""> <li class="">
...@@ -254,13 +254,13 @@ ...@@ -254,13 +254,13 @@
</ul> </ul>
<div class="admonition note"> <div class="admonition note">
<p class="admonition-title">注意事项</p> <p class="admonition-title">注意事项</p>
</div>
<ul> <ul>
<li>此接口会改变<code>program</code>结构,并且可能增加一些<code>persistable</code>的变量,所以加载模型参数时请注意和相应的<code>program</code>对应。</li> <li>此接口会改变<code>program</code>结构,并且可能增加一些<code>persistable</code>的变量,所以加载模型参数时请注意和相应的<code>program</code>对应。</li>
<li>此接口底层经历了<code>fluid.Program</code>-&gt; <code>fluid.framework.IrGraph</code>-&gt;<code>fluid.Program</code>的转变,在<code>fluid.framework.IrGraph</code>中没有<code>Parameter</code>的概念,<code>Variable</code>只有<code>persistable</code><code>not persistable</code>的区别,所以在保存和加载参数时,请使用<code>fluid.io.save_persistables</code><code>fluid.io.load_persistables</code>接口。</li> <li>此接口底层经历了<code>fluid.Program</code>-&gt; <code>fluid.framework.IrGraph</code>-&gt;<code>fluid.Program</code>的转变,在<code>fluid.framework.IrGraph</code>中没有<code>Parameter</code>的概念,<code>Variable</code>只有<code>persistable</code><code>not persistable</code>的区别,所以在保存和加载参数时,请使用<code>fluid.io.save_persistables</code><code>fluid.io.load_persistables</code>接口。</li>
<li>由于此接口会根据<code>program</code>的结构和量化配置来对<code>program</code>添加op,所以<code>Paddle</code>中一些通过<code>fuse op</code>来加速训练的策略不能使用。已知以下策略在使用量化时必须设为<code>False</code><code>fuse_all_reduce_ops, sync_batch_norm</code></li> <li>由于此接口会根据<code>program</code>的结构和量化配置来对<code>program</code>添加op,所以<code>Paddle</code>中一些通过<code>fuse op</code>来加速训练的策略不能使用。已知以下策略在使用量化时必须设为<code>False</code><code>fuse_all_reduce_ops, sync_batch_norm</code></li>
<li>如果传入的<code>program</code>中存在和任何op都没有连接的<code>Variable</code>,则会在量化的过程中被优化掉。</li> <li>如果传入的<code>program</code>中存在和任何op都没有连接的<code>Variable</code>,则会在量化的过程中被优化掉。</li>
</ul> </ul>
</div>
<h2 id="convert">convert<a class="headerlink" href="#convert" title="Permanent link">#</a></h2> <h2 id="convert">convert<a class="headerlink" href="#convert" title="Permanent link">#</a></h2>
<dl> <dl>
<dt>paddleslim.quant.convert(program, place, config, scope=None, save_int8=False)<a href="https://github.com/PaddlePaddle/PaddleSlim/blob/develop/paddleslim/quant/quanter.py">[源代码]</a></dt> <dt>paddleslim.quant.convert(program, place, config, scope=None, save_int8=False)<a href="https://github.com/PaddlePaddle/PaddleSlim/blob/develop/paddleslim/quant/quanter.py">[源代码]</a></dt>
...@@ -283,8 +283,8 @@ ...@@ -283,8 +283,8 @@
</ul> </ul>
<div class="admonition note"> <div class="admonition note">
<p class="admonition-title">注意事项</p> <p class="admonition-title">注意事项</p>
</div>
<p>因为该接口会对<code>op</code><code>Variable</code>做相应的删除和修改,所以此接口只能在训练完成之后调用。如果想转化训练的中间模型,可加载相应的参数之后再使用此接口。</p> <p>因为该接口会对<code>op</code><code>Variable</code>做相应的删除和修改,所以此接口只能在训练完成之后调用。如果想转化训练的中间模型,可加载相应的参数之后再使用此接口。</p>
</div>
<p><strong>代码示例</strong></p> <p><strong>代码示例</strong></p>
<table class="codehilitetable"><tr><td class="linenos"><div class="linenodiv"><pre><span></span> 1 <table class="codehilitetable"><tr><td class="linenos"><div class="linenodiv"><pre><span></span> 1
2 2
...@@ -388,8 +388,8 @@ ...@@ -388,8 +388,8 @@
<p>无。</p> <p>无。</p>
<div class="admonition note"> <div class="admonition note">
<p class="admonition-title">注意事项</p> <p class="admonition-title">注意事项</p>
</div>
<p>因为该接口会收集校正数据的所有的激活值,所以使用的校正图片不能太多。<code>'KL'</code>散度的计算也比较耗时。</p> <p>因为该接口会收集校正数据的所有的激活值,所以使用的校正图片不能太多。<code>'KL'</code>散度的计算也比较耗时。</p>
</div>
<p><strong>代码示例</strong></p> <p><strong>代码示例</strong></p>
<blockquote> <blockquote>
<p>注: 此示例不能直接运行,因为需要加载<code>${model_dir}</code>下的模型,所以不能直接运行。</p> <p>注: 此示例不能直接运行,因为需要加载<code>${model_dir}</code>下的模型,所以不能直接运行。</p>
......
...@@ -129,7 +129,7 @@ ...@@ -129,7 +129,7 @@
</li> </li>
<li class=""> <li class="">
<a class="" href="../search_space/">搜索空间</a> <a class="" href="../search_space.md">搜索空间</a>
</li> </li>
<li class=""> <li class="">
......
...@@ -129,7 +129,7 @@ ...@@ -129,7 +129,7 @@
</li> </li>
<li class=""> <li class="">
<a class="" href="api/search_space/">搜索空间</a> <a class="" href="api/search_space.md">搜索空间</a>
</li> </li>
<li class=""> <li class="">
...@@ -293,5 +293,5 @@ ...@@ -293,5 +293,5 @@
<!-- <!--
MkDocs version : 1.0.4 MkDocs version : 1.0.4
Build Date UTC : 2020-01-09 05:24:41 Build Date UTC : 2020-01-09 06:39:56
--> -->
...@@ -151,7 +151,7 @@ ...@@ -151,7 +151,7 @@
</li> </li>
<li class=""> <li class="">
<a class="" href="../api/search_space/">搜索空间</a> <a class="" href="../api/search_space.md">搜索空间</a>
</li> </li>
<li class=""> <li class="">
......
...@@ -104,7 +104,7 @@ ...@@ -104,7 +104,7 @@
</li> </li>
<li class=""> <li class="">
<a class="" href="./api/search_space/">搜索空间</a> <a class="" href="./api/search_space.md">搜索空间</a>
</li> </li>
<li class=""> <li class="">
......
此差异已折叠。
...@@ -7,23 +7,23 @@ ...@@ -7,23 +7,23 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="shortcut icon" href="../../img/favicon.ico"> <link rel="shortcut icon" href="../img/favicon.ico">
<title>搜索空间 - PaddleSlim Docs</title> <title>Search space - PaddleSlim Docs</title>
<link href='https://fonts.googleapis.com/css?family=Lato:400,700|Roboto+Slab:400,700|Inconsolata:400,700' rel='stylesheet' type='text/css'> <link href='https://fonts.googleapis.com/css?family=Lato:400,700|Roboto+Slab:400,700|Inconsolata:400,700' rel='stylesheet' type='text/css'>
<link rel="stylesheet" href="../../css/theme.css" type="text/css" /> <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="../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"> <link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/styles/github.min.css">
<script> <script>
// Current page data // Current page data
var mkdocs_page_name = "\u641c\u7d22\u7a7a\u95f4"; var mkdocs_page_name = "Search space";
var mkdocs_page_input_path = "api/search_space.md"; var mkdocs_page_input_path = "search_space.md";
var mkdocs_page_url = null; var mkdocs_page_url = null;
</script> </script>
<script src="../../js/jquery-2.1.1.min.js" defer></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="../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 src="//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/highlight.min.js"></script>
<script>hljs.initHighlightingOnLoad();</script> <script>hljs.initHighlightingOnLoad();</script>
...@@ -36,9 +36,9 @@ ...@@ -36,9 +36,9 @@
<nav data-toggle="wy-nav-shift" class="wy-nav-side stickynav"> <nav data-toggle="wy-nav-shift" class="wy-nav-side stickynav">
<div class="wy-side-nav-search"> <div class="wy-side-nav-search">
<a href="../.." class="icon icon-home"> PaddleSlim Docs</a> <a href=".." class="icon icon-home"> PaddleSlim Docs</a>
<div role="search"> <div role="search">
<form id ="rtd-search-form" class="wy-form" action="../../search.html" method="get"> <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" /> <input type="text" name="q" placeholder="Search docs" title="Type search term here" />
</form> </form>
</div> </div>
...@@ -50,12 +50,12 @@ ...@@ -50,12 +50,12 @@
<li class="toctree-l1"> <li class="toctree-l1">
<a class="" href="../..">Home</a> <a class="" href="..">Home</a>
</li> </li>
<li class="toctree-l1"> <li class="toctree-l1">
<a class="" href="../../model_zoo/">模型库</a> <a class="" href="../model_zoo/">模型库</a>
</li> </li>
<li class="toctree-l1"> <li class="toctree-l1">
...@@ -64,23 +64,23 @@ ...@@ -64,23 +64,23 @@
<ul class="subnav"> <ul class="subnav">
<li class=""> <li class="">
<a class="" href="../../tutorials/quant_post_demo/">离线量化</a> <a class="" href="../tutorials/quant_post_demo/">离线量化</a>
</li> </li>
<li class=""> <li class="">
<a class="" href="../../tutorials/quant_aware_demo/">量化训练</a> <a class="" href="../tutorials/quant_aware_demo/">量化训练</a>
</li> </li>
<li class=""> <li class="">
<a class="" href="../../tutorials/quant_embedding_demo/">Embedding量化</a> <a class="" href="../tutorials/quant_embedding_demo/">Embedding量化</a>
</li> </li>
<li class=""> <li class="">
<a class="" href="../../tutorials/nas_demo/">SA搜索</a> <a class="" href="../tutorials/nas_demo/">SA搜索</a>
</li> </li>
<li class=""> <li class="">
<a class="" href="../../tutorials/distillation_demo/">知识蒸馏</a> <a class="" href="../tutorials/distillation_demo/">知识蒸馏</a>
</li> </li>
</ul> </ul>
</li> </li>
...@@ -91,55 +91,38 @@ ...@@ -91,55 +91,38 @@
<ul class="subnav"> <ul class="subnav">
<li class=""> <li class="">
<a class="" href="../quantization_api/">量化</a> <a class="" href="../api/quantization_api/">量化</a>
</li> </li>
<li class=""> <li class="">
<a class="" href="../prune_api/">剪枝与敏感度</a> <a class="" href="../api/prune_api/">剪枝与敏感度</a>
</li> </li>
<li class=""> <li class="">
<a class="" href="../analysis_api/">模型分析</a> <a class="" href="../api/analysis_api/">模型分析</a>
</li> </li>
<li class=""> <li class="">
<a class="" href="../single_distiller_api/">知识蒸馏</a> <a class="" href="../api/single_distiller_api/">知识蒸馏</a>
</li> </li>
<li class=""> <li class="">
<a class="" href="../nas_api/">SA搜索</a> <a class="" href="../api/nas_api/">SA搜索</a>
</li> </li>
<li class=" current"> <li class="">
<a class="current" href="./">搜索空间</a>
<ul class="subnav">
<li class="toctree-l3"><a href="#paddleslimnas">paddleslim.nas 提供的搜索空间:</a></li>
<ul>
<li><a class="toctree-l4" href="#_1">搜索空间的配置介绍:</a></li>
<li><a class="toctree-l4" href="#_2">搜索空间示例:</a></li>
</ul>
<li class="toctree-l3"><a href="#search-space">自定义搜索空间(search space)</a></li>
</ul> <a class="" href="../api/search_space.md">搜索空间</a>
</li> </li>
<li class=""> <li class="">
<a class="" href="../../table_latency/">硬件延时评估表</a> <a class="" href="../table_latency/">硬件延时评估表</a>
</li> </li>
</ul> </ul>
</li> </li>
<li class="toctree-l1"> <li class="toctree-l1">
<a class="" href="../../algo/algo/">算法原理</a> <a class="" href="../algo/algo/">算法原理</a>
</li> </li>
</ul> </ul>
...@@ -152,7 +135,7 @@ ...@@ -152,7 +135,7 @@
<nav class="wy-nav-top" role="navigation" aria-label="top navigation"> <nav class="wy-nav-top" role="navigation" aria-label="top navigation">
<i data-toggle="wy-nav-top" class="fa fa-bars"></i> <i data-toggle="wy-nav-top" class="fa fa-bars"></i>
<a href="../..">PaddleSlim Docs</a> <a href="..">PaddleSlim Docs</a>
</nav> </nav>
...@@ -160,18 +143,14 @@ ...@@ -160,18 +143,14 @@
<div class="rst-content"> <div class="rst-content">
<div role="navigation" aria-label="breadcrumbs navigation"> <div role="navigation" aria-label="breadcrumbs navigation">
<ul class="wy-breadcrumbs"> <ul class="wy-breadcrumbs">
<li><a href="../..">Docs</a> &raquo;</li> <li><a href="..">Docs</a> &raquo;</li>
<li>API &raquo;</li>
<li>Search space</li>
<li>搜索空间</li>
<li class="wy-breadcrumbs-aside"> <li class="wy-breadcrumbs-aside">
<a href="https://github.com/PaddlePaddle/PaddleSlim/blob/develop/docs/docs/api/search_space.md" <a href="https://github.com/PaddlePaddle/PaddleSlim/blob/develop/docs/docs/search_space.md"
class="icon icon-github"> Edit on GitHub</a> class="icon icon-github"> Edit on GitHub</a>
</li> </li>
...@@ -181,41 +160,61 @@ ...@@ -181,41 +160,61 @@
<div role="main"> <div role="main">
<div class="section"> <div class="section">
<h1 id="paddleslimnas">paddleslim.nas 提供的搜索空间:<a class="headerlink" href="#paddleslimnas" title="Permanent link">#</a></h1> <h2 id="_1">搜索空间简介<a class="headerlink" href="#_1" title="Permanent link">#</a></h2>
<dl>
<dd>搜索空间是神经网络搜索中的一个概念。搜索空间是一系列模型结构的汇集, SANAS主要是利用模拟退火的思想在搜索空间中搜索到一个比较小的模型结构或者一个精度比较高的模型结构。</dd>
</dl>
<h2 id="paddleslimnas">paddleslim.nas 提供的搜索空间<a class="headerlink" href="#paddleslimnas" title="Permanent link">#</a></h2>
<h5 id="_2">根据初始模型结构构造搜索空间<a class="headerlink" href="#_2" title="Permanent link">#</a></h5>
<ol> <ol>
<li>根据原本模型结构构造搜索空间:</li> <li>
<p>MobileNetV2Space<br>
&emsp; MobileNetV2的网络结构可以参考:<a href="https://github.com/PaddlePaddle/models/blob/develop/PaddleCV/image_classification/models/mobilenet_v2.py#L29">代码</a><a href="https://arxiv.org/abs/1801.04381">论文</a></p>
</li>
<li>
<p>MobileNetV1Space<br>
&emsp; MobilNetV1的网络结构可以参考:<a href="https://github.com/PaddlePaddle/models/blob/develop/PaddleCV/image_classification/models/mobilenet_v1.py#L29">代码</a><a href="https://arxiv.org/abs/1704.04861">论文</a></p>
</li>
<li>
<p>ResNetSpace<br>
&emsp; ResNetSpace的网络结构可以参考:<a href="https://github.com/PaddlePaddle/models/blob/develop/PaddleCV/image_classification/models/resnet.py#L30">代码</a><a href="https://arxiv.org/pdf/1512.03385.pdf">论文</a></p>
</li>
</ol> </ol>
<p>1.1 MobileNetV2Space</p> <h5 id="block">根据相应模型的block构造搜索空间<a class="headerlink" href="#block" title="Permanent link">#</a></h5>
<p>1.2 MobileNetV1Space</p>
<p>1.3 ResNetSpace</p>
<ol> <ol>
<li>根据相应模型的block构造搜索空间</li> <li>
<p>MobileNetV1BlockSpace<br>
&emsp; MobileNetV1Block的结构可以参考:<a href="https://github.com/PaddlePaddle/models/blob/develop/PaddleCV/image_classification/models/mobilenet_v1.py#L173">代码</a></p>
</li>
<li>
<p>MobileNetV2BlockSpace<br>
&emsp; MobileNetV2Block的结构可以参考:<a href="https://github.com/PaddlePaddle/models/blob/develop/PaddleCV/image_classification/models/mobilenet_v2.py#L174">代码</a></p>
</li>
<li>
<p>ResNetBlockSpace<br>
&emsp; ResNetBlock的结构可以参考:<a href="https://github.com/PaddlePaddle/models/blob/develop/PaddleCV/image_classification/models/resnet.py#L148">代码</a></p>
</li>
<li>
<p>InceptionABlockSpace<br>
&emsp; InceptionABlock的结构可以参考:<a href="https://github.com/PaddlePaddle/models/blob/develop/PaddleCV/image_classification/models/inception_v4.py#L140">代码</a></p>
</li>
<li>
<p>InceptionCBlockSpace<br>
&emsp; InceptionCBlock结构可以参考:<a href="https://github.com/PaddlePaddle/models/blob/develop/PaddleCV/image_classification/models/inception_v4.py#L291">代码</a></p>
</li>
</ol> </ol>
<p>2.1 MobileNetV1BlockSpace</p> <h2 id="_3">搜索空间示例<a class="headerlink" href="#_3" title="Permanent link">#</a></h2>
<p>2.2 MobileNetV2BlockSpace</p>
<p>2.3 ResNetBlockSpace</p>
<p>2.4 InceptionABlockSpace</p>
<p>2.5 InceptionCBlockSpace</p>
<h2 id="_1">搜索空间的配置介绍:<a class="headerlink" href="#_1" title="Permanent link">#</a></h2>
<p><strong>input_size(int|None)</strong><code>input_size</code>表示输入feature map的大小。
<strong>output_size(int|None)</strong><code>output_size</code>表示输出feature map的大小。
<strong>block_num(int|None)</strong><code>block_num</code>表示搜索空间中block的数量。
<strong>block_mask(list|None)</strong><code>block_mask</code>表示当前的block是一个reduction block还是一个normal block,是一组由0、1组成的列表,0表示当前block是normal block,1表示当前block是reduction block。如果设置了<code>block_mask</code>,则主要以<code>block_mask</code>为主要配置,<code>input_size</code><code>output_size</code><code>block_num</code>三种配置是无效的。</p>
<p><strong>Note:</strong>
1. reduction block表示经过这个block之后的feature map大小下降为之前的一半,normal block表示经过这个block之后feature map大小不变。
2. <code>input_size</code><code>output_size</code>用来计算整个模型结构中reduction block数量。</p>
<h2 id="_2">搜索空间示例:<a class="headerlink" href="#_2" title="Permanent link">#</a></h2>
<ol> <ol>
<li>使用paddleslim中提供用原本的模型结构来构造搜索空间的话,仅需要指定搜索空间名字即可。例如:如果使用原本的MobileNetV2的搜索空间进行搜索的话,传入SANAS中的config直接指定为[('MobileNetV2Space')]。</li> <li>使用paddleslim中提供用初始的模型结构来构造搜索空间的话,仅需要指定搜索空间名字即可。例如:如果使用原本的MobileNetV2的搜索空间进行搜索的话,传入SANAS中的config直接指定为[('MobileNetV2Space')]。</li>
<li>使用paddleslim中提供的block搜索空间构造搜索空间: <li>使用paddleslim中提供的block搜索空间构造搜索空间:<br>
2.1 使用<code>input_size</code>, <code>output_size</code><code>block_num</code>来构造搜索空间。例如:传入SANAS的config可以指定为[('MobileNetV2BlockSpace', {'input_size': 224, 'output_size': 32, 'block_num': 10})]。 2.1 使用<code>input_size</code>, <code>output_size</code><code>block_num</code>来构造搜索空间。例如:传入SANAS的config可以指定为[('MobileNetV2BlockSpace', {'input_size': 224, 'output_size': 32, 'block_num': 10})]。<br>
2.2 使用<code>block_mask</code>构造搜索空间。例如:传入SANAS的config可以指定为[('MobileNetV2BlockSpace', {'block_mask': [0, 1, 1, 1, 1, 0, 1, 0]})]。</li> 2.2 使用<code>block_mask</code>构造搜索空间。例如:传入SANAS的config可以指定为[('MobileNetV2BlockSpace', {'block_mask': [0, 1, 1, 1, 1, 0, 1, 0]})]。</li>
</ol> </ol>
<h1 id="search-space">自定义搜索空间(search space)<a class="headerlink" href="#search-space" title="Permanent link">#</a></h1> <h2 id="search-space">自定义搜索空间(search space)<a class="headerlink" href="#search-space" title="Permanent link">#</a></h2>
<p>自定义搜索空间类需要继承搜索空间基类并重写以下几部分: <p>自定义搜索空间类需要继承搜索空间基类并重写以下几部分:<br>
1. 初始化的tokens(<code>init_tokens</code>函数),可以设置为自己想要的tokens列表, tokens列表中的每个数字指的是当前数字在相应的搜索列表中的索引。例如本示例中若tokens=[0, 3, 5],则代表当前模型结构搜索到的通道数为[8, 40, 128]。 &emsp; 1. 初始化的tokens(<code>init_tokens</code>函数),可以设置为自己想要的tokens列表, tokens列表中的每个数字指的是当前数字在相应的搜索列表中的索引。例如本示例中若tokens=[0, 3, 5],则代表当前模型结构搜索到的通道数为[8, 40, 128]。<br>
2. token中每个数字的搜索列表长度(<code>range_table</code>函数),tokens中每个token的索引范围。 &emsp; 2. token中每个数字的搜索列表长度(<code>range_table</code>函数),tokens中每个token的索引范围。<br>
3. 根据token产生模型结构(<code>token2arch</code>函数),根据搜索到的tokens列表产生模型结构。</p> &emsp; 3. 根据token产生模型结构(<code>token2arch</code>函数),根据搜索到的tokens列表产生模型结构。 <br></p>
<p>以新增reset block为例说明如何构造自己的search space。自定义的search space不能和已有的search space同名。</p> <p>以新增reset block为例说明如何构造自己的search space。自定义的search space不能和已有的search space同名。</p>
<table class="codehilitetable"><tr><td class="linenos"><div class="linenodiv"><pre><span></span> 1 <table class="codehilitetable"><tr><td class="linenos"><div class="linenodiv"><pre><span></span> 1
2 2
...@@ -277,7 +276,8 @@ ...@@ -277,7 +276,8 @@
58 58
59 59
60 60
61</pre></div></td><td class="code"><div class="codehilite"><pre><span></span><span class="c1">### 引入搜索空间基类函数和search space的注册类函数</span> 61
62</pre></div></td><td class="code"><div class="codehilite"><pre><span></span><span class="c1">### 引入搜索空间基类函数和search space的注册类函数</span>
<span class="kn">from</span> <span class="nn">.search_space_base</span> <span class="kn">import</span> <span class="n">SearchSpaceBase</span> <span class="kn">from</span> <span class="nn">.search_space_base</span> <span class="kn">import</span> <span class="n">SearchSpaceBase</span>
<span class="kn">from</span> <span class="nn">.search_space_registry</span> <span class="kn">import</span> <span class="n">SEARCHSPACE</span> <span class="kn">from</span> <span class="nn">.search_space_registry</span> <span class="kn">import</span> <span class="n">SEARCHSPACE</span>
<span class="kn">import</span> <span class="nn">numpy</span> <span class="kn">as</span> <span class="nn">np</span> <span class="kn">import</span> <span class="nn">numpy</span> <span class="kn">as</span> <span class="nn">np</span>
...@@ -295,10 +295,11 @@ ...@@ -295,10 +295,11 @@
<span class="k">def</span> <span class="nf">init_tokens</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> <span class="k">def</span> <span class="nf">init_tokens</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="k">return</span> <span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">*</span> <span class="mi">3</span> <span class="o">*</span> <span class="nb">len</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">block_mask</span><span class="p">)</span> <span class="k">return</span> <span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">*</span> <span class="mi">3</span> <span class="o">*</span> <span class="nb">len</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">block_mask</span><span class="p">)</span>
<span class="c1">### 定义</span> <span class="c1">### 定义token的index的取值范围</span>
<span class="k">def</span> <span class="nf">range_table</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> <span class="k">def</span> <span class="nf">range_table</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="k">return</span> <span class="p">[</span><span class="nb">len</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">filter_num</span><span class="p">)]</span> <span class="o">*</span> <span class="mi">3</span> <span class="o">*</span> <span class="nb">len</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">block_mask</span><span class="p">)</span> <span class="k">return</span> <span class="p">[</span><span class="nb">len</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">filter_num</span><span class="p">)]</span> <span class="o">*</span> <span class="mi">3</span> <span class="o">*</span> <span class="nb">len</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">block_mask</span><span class="p">)</span>
<span class="c1">### 把token转换成模型结构</span>
<span class="k">def</span> <span class="nf">token2arch</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">tokens</span><span class="o">=</span><span class="bp">None</span><span class="p">):</span> <span class="k">def</span> <span class="nf">token2arch</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">tokens</span><span class="o">=</span><span class="bp">None</span><span class="p">):</span>
<span class="k">if</span> <span class="n">tokens</span> <span class="o">==</span> <span class="bp">None</span><span class="p">:</span> <span class="k">if</span> <span class="n">tokens</span> <span class="o">==</span> <span class="bp">None</span><span class="p">:</span>
<span class="n">tokens</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">init_tokens</span><span class="p">()</span> <span class="n">tokens</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">init_tokens</span><span class="p">()</span>
...@@ -345,15 +346,6 @@ ...@@ -345,15 +346,6 @@
</div> </div>
<footer> <footer>
<div class="rst-footer-buttons" role="navigation" aria-label="footer navigation">
<a href="../../table_latency/" class="btn btn-neutral float-right" title="硬件延时评估表">Next <span class="icon icon-circle-arrow-right"></span></a>
<a href="../nas_api/" class="btn btn-neutral" title="SA搜索"><span class="icon icon-circle-arrow-left"></span> Previous</a>
</div>
<hr/> <hr/>
...@@ -378,18 +370,14 @@ ...@@ -378,18 +370,14 @@
<a href="https://github.com/PaddlePaddle/PaddleSlim/" class="fa fa-github" style="float: left; color: #fcfcfc"> GitHub</a> <a href="https://github.com/PaddlePaddle/PaddleSlim/" class="fa fa-github" style="float: left; color: #fcfcfc"> GitHub</a>
<span><a href="../nas_api/" style="color: #fcfcfc;">&laquo; Previous</a></span>
<span style="margin-left: 15px"><a href="../../table_latency/" style="color: #fcfcfc">Next &raquo;</a></span>
</span> </span>
</div> </div>
<script>var base_url = '../..';</script> <script>var base_url = '..';</script>
<script src="../../js/theme.js" defer></script> <script src="../js/theme.js" defer></script>
<script src="../../mathjax-config.js" defer></script> <script src="../mathjax-config.js" defer></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js?config=TeX-AMS-MML_HTMLorMML" defer></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js?config=TeX-AMS-MML_HTMLorMML" defer></script>
<script src="../../search/main.js" defer></script> <script src="../search/main.js" defer></script>
</body> </body>
</html> </html>
...@@ -61,8 +61,8 @@ ...@@ -61,8 +61,8 @@
<changefreq>daily</changefreq> <changefreq>daily</changefreq>
</url> </url>
<url> <url>
<loc>None</loc> <loc></loc>
<lastmod>2020-01-09</lastmod>
<changefreq>daily</changefreq> <changefreq>daily</changefreq>
</url> </url>
<url> <url>
......
无法预览此类型文件
...@@ -111,7 +111,7 @@ ...@@ -111,7 +111,7 @@
</li> </li>
<li class=""> <li class="">
<a class="" href="../api/search_space/">搜索空间</a> <a class="" href="../api/search_space.md">搜索空间</a>
</li> </li>
<li class=" current"> <li class=" current">
...@@ -322,7 +322,7 @@ ...@@ -322,7 +322,7 @@
<a href="../algo/algo/" class="btn btn-neutral float-right" title="算法原理">Next <span class="icon icon-circle-arrow-right"></span></a> <a href="../algo/algo/" class="btn btn-neutral float-right" title="算法原理">Next <span class="icon icon-circle-arrow-right"></span></a>
<a href="../api/search_space/" class="btn btn-neutral" title="搜索空间"><span class="icon icon-circle-arrow-left"></span> Previous</a> <a href="../api/nas_api/" class="btn btn-neutral" title="SA搜索"><span class="icon icon-circle-arrow-left"></span> Previous</a>
</div> </div>
...@@ -350,7 +350,7 @@ ...@@ -350,7 +350,7 @@
<a href="https://github.com/PaddlePaddle/PaddleSlim/" class="fa fa-github" style="float: left; color: #fcfcfc"> GitHub</a> <a href="https://github.com/PaddlePaddle/PaddleSlim/" class="fa fa-github" style="float: left; color: #fcfcfc"> GitHub</a>
<span><a href="../api/search_space/" style="color: #fcfcfc;">&laquo; Previous</a></span> <span><a href="../api/nas_api/" style="color: #fcfcfc;">&laquo; Previous</a></span>
<span style="margin-left: 15px"><a href="../algo/algo/" style="color: #fcfcfc">Next &raquo;</a></span> <span style="margin-left: 15px"><a href="../algo/algo/" style="color: #fcfcfc">Next &raquo;</a></span>
......
...@@ -111,7 +111,7 @@ ...@@ -111,7 +111,7 @@
</li> </li>
<li class=""> <li class="">
<a class="" href="../../api/search_space/">搜索空间</a> <a class="" href="../../api/search_space.md">搜索空间</a>
</li> </li>
<li class=""> <li class="">
......
...@@ -134,7 +134,7 @@ ...@@ -134,7 +134,7 @@
</li> </li>
<li class=""> <li class="">
<a class="" href="../../api/search_space/">搜索空间</a> <a class="" href="../../api/search_space.md">搜索空间</a>
</li> </li>
<li class=""> <li class="">
......
...@@ -123,7 +123,7 @@ ...@@ -123,7 +123,7 @@
</li> </li>
<li class=""> <li class="">
<a class="" href="../../api/search_space/">搜索空间</a> <a class="" href="../../api/search_space.md">搜索空间</a>
</li> </li>
<li class=""> <li class="">
...@@ -181,7 +181,7 @@ ...@@ -181,7 +181,7 @@
<h2 id="_2">接口介绍<a class="headerlink" href="#_2" title="Permanent link">#</a></h2> <h2 id="_2">接口介绍<a class="headerlink" href="#_2" title="Permanent link">#</a></h2>
<p>请参考。</p> <p>请参考。</p>
<h3 id="1">1. 配置搜索空间<a class="headerlink" href="#1" title="Permanent link">#</a></h3> <h3 id="1">1. 配置搜索空间<a class="headerlink" href="#1" title="Permanent link">#</a></h3>
<p>详细的搜索空间配置可以参考<a href='../../../paddleslim/nas/nas_api.md'>神经网络搜索API文档</a> <p>详细的搜索空间配置可以参考<a href="https://paddlepaddle.github.io/PaddleSlim/api/nas_api/">神经网络搜索API文档</a>
<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">config</span> <span class="o">=</span> <span class="p">[(</span><span class="s1">&#39;MobileNetV2Space&#39;</span><span class="p">)]</span> <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">config</span> <span class="o">=</span> <span class="p">[(</span><span class="s1">&#39;MobileNetV2Space&#39;</span><span class="p">)]</span>
</pre></div> </pre></div>
</td></tr></table></p> </td></tr></table></p>
......
...@@ -111,7 +111,7 @@ ...@@ -111,7 +111,7 @@
</li> </li>
<li class=""> <li class="">
<a class="" href="../../api/search_space/">搜索空间</a> <a class="" href="../../api/search_space.md">搜索空间</a>
</li> </li>
<li class=""> <li class="">
......
...@@ -125,7 +125,7 @@ ...@@ -125,7 +125,7 @@
</li> </li>
<li class=""> <li class="">
<a class="" href="../../api/search_space/">搜索空间</a> <a class="" href="../../api/search_space.md">搜索空间</a>
</li> </li>
<li class=""> <li class="">
...@@ -181,7 +181,7 @@ ...@@ -181,7 +181,7 @@
<h1 id="_1">在线量化示例<a class="headerlink" href="#_1" title="Permanent link">#</a></h1> <h1 id="_1">在线量化示例<a class="headerlink" href="#_1" title="Permanent link">#</a></h1>
<p>本示例介绍如何使用在线量化接口,来对训练好的分类模型进行量化, 可以减少模型的存储空间和显存占用。</p> <p>本示例介绍如何使用在线量化接口,来对训练好的分类模型进行量化, 可以减少模型的存储空间和显存占用。</p>
<h2 id="_2">接口介绍<a class="headerlink" href="#_2" title="Permanent link">#</a></h2> <h2 id="_2">接口介绍<a class="headerlink" href="#_2" title="Permanent link">#</a></h2>
<p>请参考 <a href='../../../paddleslim/quant/quantization_api_doc.md'>量化API文档</a></p> <p>请参考 <a href="https://paddlepaddle.github.io/PaddleSlim/api/quantization_api/">量化API文档</a></p>
<h2 id="_3">分类模型的离线量化流程<a class="headerlink" href="#_3" title="Permanent link">#</a></h2> <h2 id="_3">分类模型的离线量化流程<a class="headerlink" href="#_3" title="Permanent link">#</a></h2>
<h3 id="1">1. 配置量化参数<a class="headerlink" href="#1" title="Permanent link">#</a></h3> <h3 id="1">1. 配置量化参数<a class="headerlink" href="#1" title="Permanent link">#</a></h3>
<table class="codehilitetable"><tr><td class="linenos"><div class="linenodiv"><pre><span></span> 1 <table class="codehilitetable"><tr><td class="linenos"><div class="linenodiv"><pre><span></span> 1
......
...@@ -125,7 +125,7 @@ ...@@ -125,7 +125,7 @@
</li> </li>
<li class=""> <li class="">
<a class="" href="../../api/search_space/">搜索空间</a> <a class="" href="../../api/search_space.md">搜索空间</a>
</li> </li>
<li class=""> <li class="">
...@@ -179,18 +179,18 @@ ...@@ -179,18 +179,18 @@
<div class="section"> <div class="section">
<h1 id="embedding">Embedding量化示例<a class="headerlink" href="#embedding" title="Permanent link">#</a></h1> <h1 id="embedding">Embedding量化示例<a class="headerlink" href="#embedding" title="Permanent link">#</a></h1>
<p>本示例介绍如何使用Embedding量化的接口 <a href="">paddleslim.quant.quant_embedding</a><code>quant_embedding</code>接口将网络中的Embedding参数从<code>float32</code>类型量化到 <code>8-bit</code>整数类型,在几乎不损失模型精度的情况下减少模型的存储空间和显存占用。</p> <p>本示例介绍如何使用Embedding量化的接口 <a href="https://paddlepaddle.github.io/PaddleSlim/api/quantization_api/">paddleslim.quant.quant_embedding</a><code>quant_embedding</code>接口将网络中的Embedding参数从<code>float32</code>类型量化到 <code>8-bit</code>整数类型,在几乎不损失模型精度的情况下减少模型的存储空间和显存占用。</p>
<p>接口介绍请参考 <a href='../../../paddleslim/quant/quantization_api_doc.md'>量化API文档</a></p> <p>接口介绍请参考 <a href="https://paddlepaddle.github.io/PaddleSlim/api/quantization_api/">量化API文档</a></p>
<p>该接口对program的修改:</p> <p>该接口对program的修改:</p>
<p>量化前:</p> <p>量化前:</p>
<p align="center"> <p align="center">
<img src="./image/before.png" height=200 width=100 hspace='10'/> <br /> <img src="https://raw.githubusercontent.com/PaddlePaddle/PaddleSlim/develop/demo/quant/quant_embedding/image/before.png" height=200 width=100 hspace='10'/> <br />
<strong>图1:量化前的模型结构</strong> <strong>图1:量化前的模型结构</strong>
</p> </p>
<p>量化后:</p> <p>量化后:</p>
<p align="center"> <p align="center">
<img src="./image/after.png" height=300 width=300 hspace='10'/> <br /> <img src="https://raw.githubusercontent.com/PaddlePaddle/PaddleSlim/develop/demo/quant/quant_embedding/image/after.png" height=300 width=300 hspace='10'/> <br />
<strong>图2: 量化后的模型结构</strong> <strong>图2: 量化后的模型结构</strong>
</p> </p>
......
...@@ -125,7 +125,7 @@ ...@@ -125,7 +125,7 @@
</li> </li>
<li class=""> <li class="">
<a class="" href="../../api/search_space/">搜索空间</a> <a class="" href="../../api/search_space.md">搜索空间</a>
</li> </li>
<li class=""> <li class="">
...@@ -181,7 +181,7 @@ ...@@ -181,7 +181,7 @@
<h1 id="_1">离线量化示例<a class="headerlink" href="#_1" title="Permanent link">#</a></h1> <h1 id="_1">离线量化示例<a class="headerlink" href="#_1" title="Permanent link">#</a></h1>
<p>本示例介绍如何使用离线量化接口<code>paddleslim.quant.quant_post</code>来对训练好的分类模型进行离线量化, 该接口无需对模型进行训练就可得到量化模型,减少模型的存储空间和显存占用。</p> <p>本示例介绍如何使用离线量化接口<code>paddleslim.quant.quant_post</code>来对训练好的分类模型进行离线量化, 该接口无需对模型进行训练就可得到量化模型,减少模型的存储空间和显存占用。</p>
<h2 id="_2">接口介绍<a class="headerlink" href="#_2" title="Permanent link">#</a></h2> <h2 id="_2">接口介绍<a class="headerlink" href="#_2" title="Permanent link">#</a></h2>
<p>请参考 <a href='../../../paddleslim/quant/quantization_api_doc.md'>量化API文档</a></p> <p>请参考 <a href="https://paddlepaddle.github.io/PaddleSlim/api/quantization_api/">量化API文档</a></p>
<h2 id="_3">分类模型的离线量化流程<a class="headerlink" href="#_3" title="Permanent link">#</a></h2> <h2 id="_3">分类模型的离线量化流程<a class="headerlink" href="#_3" title="Permanent link">#</a></h2>
<h3 id="_4">准备数据<a class="headerlink" href="#_4" title="Permanent link">#</a></h3> <h3 id="_4">准备数据<a class="headerlink" href="#_4" title="Permanent link">#</a></h3>
<p>在当前文件夹下创建<code>data</code>文件夹,将<code>imagenet</code>数据集解压在<code>data</code>文件夹下,解压后<code>data</code>文件夹下应包含以下文件: <p>在当前文件夹下创建<code>data</code>文件夹,将<code>imagenet</code>数据集解压在<code>data</code>文件夹下,解压后<code>data</code>文件夹下应包含以下文件:
...@@ -200,7 +200,7 @@ ...@@ -200,7 +200,7 @@
</td></tr></table> </td></tr></table>
转化之后的模型存储在<code>inference_model/MobileNet/</code>文件夹下,可看到该文件夹下有<code>'model'</code>, <code>'weights'</code>两个文件。</p> 转化之后的模型存储在<code>inference_model/MobileNet/</code>文件夹下,可看到该文件夹下有<code>'model'</code>, <code>'weights'</code>两个文件。</p>
<h3 id="_7">离线量化<a class="headerlink" href="#_7" title="Permanent link">#</a></h3> <h3 id="_7">离线量化<a class="headerlink" href="#_7" title="Permanent link">#</a></h3>
<p>接下来对导出的模型文件进行离线量化,离线量化的脚本为<a href="./quant_post.py">quant_post.py</a>,脚本中使用接口<code>paddleslim.quant.quant_post</code>对模型进行离线量化。运行命令为: <p>接下来对导出的模型文件进行离线量化,离线量化的脚本为<a href="https://github.com/PaddlePaddle/PaddleSlim/blob/develop/demo/quant/quant_post/quant_post.py">quant_post.py</a>,脚本中使用接口<code>paddleslim.quant.quant_post</code>对模型进行离线量化。运行命令为:
<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">python</span> <span class="n">quant_post</span><span class="p">.</span><span class="n">py</span> <span class="c1">--model_path ./inference_model/MobileNet --save_path ./quant_model_train/MobileNet --model_filename model --params_filename weights</span> <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">python</span> <span class="n">quant_post</span><span class="p">.</span><span class="n">py</span> <span class="c1">--model_path ./inference_model/MobileNet --save_path ./quant_model_train/MobileNet --model_filename model --params_filename weights</span>
</pre></div> </pre></div>
</td></tr></table></p> </td></tr></table></p>
...@@ -215,7 +215,7 @@ ...@@ -215,7 +215,7 @@
<p>使用的量化算法为<code>'KL'</code>, 使用训练集中的160张图片进行量化参数的校正。</p> <p>使用的量化算法为<code>'KL'</code>, 使用训练集中的160张图片进行量化参数的校正。</p>
</blockquote> </blockquote>
<h3 id="_8">测试精度<a class="headerlink" href="#_8" title="Permanent link">#</a></h3> <h3 id="_8">测试精度<a class="headerlink" href="#_8" title="Permanent link">#</a></h3>
<p>使用<a href="./eval.py">eval.py</a>脚本对量化前后的模型进行测试,得到模型的分类精度进行对比。</p> <p>使用<a href="https://github.com/PaddlePaddle/PaddleSlim/blob/develop/demo/quant/quant_post/eval.py">eval.py</a>脚本对量化前后的模型进行测试,得到模型的分类精度进行对比。</p>
<p>首先测试量化前的模型的精度,运行以下命令: <p>首先测试量化前的模型的精度,运行以下命令:
<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">python</span> <span class="n">eval</span><span class="p">.</span><span class="n">py</span> <span class="c1">--model_path ./inference_model/MobileNet --model_name model --params_name weights</span> <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">python</span> <span class="n">eval</span><span class="p">.</span><span class="n">py</span> <span class="c1">--model_path ./inference_model/MobileNet --model_name model --params_name weights</span>
</pre></div> </pre></div>
......
...@@ -111,7 +111,7 @@ ...@@ -111,7 +111,7 @@
</li> </li>
<li class=""> <li class="">
<a class="" href="../../api/search_space/">搜索空间</a> <a class="" href="../../api/search_space.md">搜索空间</a>
</li> </li>
<li class=""> <li class="">
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册