Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleSlim
提交
7f247c6d
P
PaddleSlim
项目概览
PaddlePaddle
/
PaddleSlim
接近 2 年 前同步成功
通知
51
Star
1434
Fork
344
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
53
列表
看板
标记
里程碑
合并请求
16
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
PaddleSlim
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
53
Issue
53
列表
看板
标记
里程碑
合并请求
16
合并请求
16
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
7f247c6d
编写于
12月 31, 2019
作者:
B
baiyfbupt
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Deployed
de6b6ef1
with MkDocs version: 1.0.4
上级
79f2099f
变更
5
展开全部
隐藏空白更改
内联
并排
Showing
5 changed file
with
27 addition
and
24 deletion
+27
-24
index.html
index.html
+1
-1
search/search_index.json
search/search_index.json
+1
-1
sitemap.xml
sitemap.xml
+14
-14
sitemap.xml.gz
sitemap.xml.gz
+0
-0
tutorials/distillation_demo/index.html
tutorials/distillation_demo/index.html
+11
-8
未找到文件。
index.html
浏览文件 @
7f247c6d
...
...
@@ -288,5 +288,5 @@
<!--
MkDocs version : 1.0.4
Build Date UTC : 2019-12-3
0 08:12:44
Build Date UTC : 2019-12-3
1 02:34:53
-->
search/search_index.json
浏览文件 @
7f247c6d
此差异已折叠。
点击以展开。
sitemap.xml
浏览文件 @
7f247c6d
...
...
@@ -2,72 +2,72 @@
<urlset
xmlns=
"http://www.sitemaps.org/schemas/sitemap/0.9"
>
<url>
<loc>
None
</loc>
<lastmod>
2019-12-3
0
</lastmod>
<lastmod>
2019-12-3
1
</lastmod>
<changefreq>
daily
</changefreq>
</url>
<url>
<loc>
None
</loc>
<lastmod>
2019-12-3
0
</lastmod>
<lastmod>
2019-12-3
1
</lastmod>
<changefreq>
daily
</changefreq>
</url>
<url>
<loc>
None
</loc>
<lastmod>
2019-12-3
0
</lastmod>
<lastmod>
2019-12-3
1
</lastmod>
<changefreq>
daily
</changefreq>
</url>
<url>
<loc>
None
</loc>
<lastmod>
2019-12-3
0
</lastmod>
<lastmod>
2019-12-3
1
</lastmod>
<changefreq>
daily
</changefreq>
</url>
<url>
<loc>
None
</loc>
<lastmod>
2019-12-3
0
</lastmod>
<lastmod>
2019-12-3
1
</lastmod>
<changefreq>
daily
</changefreq>
</url>
<url>
<loc>
None
</loc>
<lastmod>
2019-12-3
0
</lastmod>
<lastmod>
2019-12-3
1
</lastmod>
<changefreq>
daily
</changefreq>
</url>
<url>
<loc>
None
</loc>
<lastmod>
2019-12-3
0
</lastmod>
<lastmod>
2019-12-3
1
</lastmod>
<changefreq>
daily
</changefreq>
</url>
<url>
<loc>
None
</loc>
<lastmod>
2019-12-3
0
</lastmod>
<lastmod>
2019-12-3
1
</lastmod>
<changefreq>
daily
</changefreq>
</url>
<url>
<loc>
None
</loc>
<lastmod>
2019-12-3
0
</lastmod>
<lastmod>
2019-12-3
1
</lastmod>
<changefreq>
daily
</changefreq>
</url>
<url>
<loc>
None
</loc>
<lastmod>
2019-12-3
0
</lastmod>
<lastmod>
2019-12-3
1
</lastmod>
<changefreq>
daily
</changefreq>
</url>
<url>
<loc>
None
</loc>
<lastmod>
2019-12-3
0
</lastmod>
<lastmod>
2019-12-3
1
</lastmod>
<changefreq>
daily
</changefreq>
</url>
<url>
<loc>
None
</loc>
<lastmod>
2019-12-3
0
</lastmod>
<lastmod>
2019-12-3
1
</lastmod>
<changefreq>
daily
</changefreq>
</url>
<url>
<loc>
None
</loc>
<lastmod>
2019-12-3
0
</lastmod>
<lastmod>
2019-12-3
1
</lastmod>
<changefreq>
daily
</changefreq>
</url>
<url>
<loc>
None
</loc>
<lastmod>
2019-12-3
0
</lastmod>
<lastmod>
2019-12-3
1
</lastmod>
<changefreq>
daily
</changefreq>
</url>
</urlset>
\ No newline at end of file
sitemap.xml.gz
浏览文件 @
7f247c6d
无法预览此类型文件
tutorials/distillation_demo/index.html
浏览文件 @
7f247c6d
...
...
@@ -182,7 +182,7 @@
<div
role=
"main"
>
<div
class=
"section"
>
<p>
本示例将介绍如何使用PaddleSlim蒸馏接口来对模型进行蒸馏训练
</p>
<p>
本示例将介绍如何使用PaddleSlim蒸馏接口来对模型进行蒸馏训练
。
</p>
<h2
id=
"_1"
>
接口介绍
<a
class=
"headerlink"
href=
"#_1"
title=
"Permanent link"
>
#
</a></h2>
<p>
请参考
<a
href=
"https://paddlepaddle.github.io/PaddleSlim/api/single_distiller_api/"
>
蒸馏API文档
</a>
。
</p>
<h2
id=
"paddleslim"
>
PaddleSlim蒸馏训练流程
<a
class=
"headerlink"
href=
"#paddleslim"
title=
"Permanent link"
>
#
</a></h2>
...
...
@@ -214,8 +214,8 @@
</td></tr></table>
<h3
id=
"2-teacher_program"
>
2. 定义teacher_program
<a
class=
"headerlink"
href=
"#2-teacher_program"
title=
"Permanent link"
>
#
</a></h3>
<p>
在定义好
teacher_program后,可以一并加载训练好的pretrained_model
</p>
<p>
在
teacher_program内需要加上
<code>
with fluid.unique_name.guard():
</code>
,保证teacher的变量命名不被student_program影响,从而跟能够正确地加载预训练参数
</p>
<p>
在定义好
<code>
teacher_program
</code>
后,可以一并加载训练好的pretrained_model。
</p>
<p>
在
<code>
teacher_program
</code>
内需要加上
<code>
with fluid.unique_name.guard():
</code>
,保证teacher的变量命名不被
<code>
student_program
</code>
影响,从而能够正确地加载预训练参数。
</p>
<table
class=
"codehilitetable"
><tr><td
class=
"linenos"
><div
class=
"linenodiv"
><pre><span></span>
1
2
3
...
...
@@ -255,7 +255,7 @@
</td></tr></table>
<h3
id=
"3"
>
3.选择特征图
<a
class=
"headerlink"
href=
"#3"
title=
"Permanent link"
>
#
</a></h3>
<p>
定义好
student_program和teacher_program后,我们需要从中两两对应地挑选出若干个特征图,留待后续为其添加知识蒸馏损失函数
</p>
<p>
定义好
<code>
student_program
</code>
和
<code>
teacher_program
</code>
后,我们需要从中两两对应地挑选出若干个特征图,留待后续为其添加知识蒸馏损失函数。
</p>
<table
class=
"codehilitetable"
><tr><td
class=
"linenos"
><div
class=
"linenodiv"
><pre><span></span>
1
2
3
...
...
@@ -304,7 +304,8 @@
</td></tr></table>
<h3
id=
"5loss"
>
5.添加蒸馏loss
<a
class=
"headerlink"
href=
"#5loss"
title=
"Permanent link"
>
#
</a></h3>
<p>
在添加蒸馏loss的过程中,可能还会引入部分变量(Variable),为了避免命名重复这里可以使用
<code>
with fluid.name_scope("distill"):
</code>
为新引入的变量加一个命名作用域
</p>
<p>
在添加蒸馏loss的过程中,可能还会引入部分变量(Variable),为了避免命名重复这里可以使用
<code>
with fluid.name_scope("distill"):
</code>
为新引入的变量加一个命名作用域。
</p>
<p>
另外需要注意的是,merge过程为
<code>
teacher_program
</code>
的变量统一加了名称前缀,默认是
<code>
"teacher_"
</code>
, 这里在添加
<code>
l2_loss
</code>
时也要为teacher的变量加上这个前缀。
</p>
<table
class=
"codehilitetable"
><tr><td
class=
"linenos"
><div
class=
"linenodiv"
><pre><span></span>
1
2
3
...
...
@@ -312,9 +313,11 @@
5
6
7
8
</pre></div></td><td
class=
"code"
><div
class=
"codehilite"
><pre><span></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>
8
9
</pre></div></td><td
class=
"code"
><div
class=
"codehilite"
><pre><span></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"
>
name_scope
</span><span
class=
"p"
>
(
</span><span
class=
"s2"
>
"
distill
"
</span><span
class=
"p"
>
):
</span>
<span
class=
"n"
>
distill_loss
</span>
<span
class=
"o"
>
=
</span>
<span
class=
"n"
>
l2_loss
</span><span
class=
"p"
>
(
</span><span
class=
"s1"
>
'
teacher_bn5c_branch2b.output.1.tmp_3
'
</span><span
class=
"p"
>
,
</span>
<span
class=
"s1"
>
'
depthwise_conv2d_11.tmp_0
'
</span><span
class=
"p"
>
,
</span>
<span
class=
"n"
>
main
</span><span
class=
"p"
>
)
</span>
<span
class=
"n"
>
distill_loss
</span>
<span
class=
"o"
>
=
</span>
<span
class=
"n"
>
l2_loss
</span><span
class=
"p"
>
(
</span><span
class=
"s1"
>
'
teacher_bn5c_branch2b.output.1.tmp_3
'
</span><span
class=
"p"
>
,
</span>
<span
class=
"s1"
>
'
depthwise_conv2d_11.tmp_0
'
</span><span
class=
"p"
>
,
</span>
<span
class=
"n"
>
student_program
</span><span
class=
"p"
>
)
</span>
<span
class=
"n"
>
distill_weight
</span>
<span
class=
"o"
>
=
</span>
<span
class=
"mi"
>
1
</span>
<span
class=
"n"
>
loss
</span>
<span
class=
"o"
>
=
</span>
<span
class=
"n"
>
avg_cost
</span>
<span
class=
"o"
>
+
</span>
<span
class=
"n"
>
distill_loss
</span>
<span
class=
"o"
>
*
</span>
<span
class=
"n"
>
distill_weight
</span>
<span
class=
"n"
>
opt
</span>
<span
class=
"o"
>
=
</span>
<span
class=
"n"
>
create_optimizer
</span><span
class=
"p"
>
()
</span>
...
...
@@ -323,7 +326,7 @@
</pre></div>
</td></tr></table>
<p>
至此,我们就得到了用于蒸馏训练的
student_program,后面就可以使用一个普通program一样对其开始训练和评估
</p>
<p>
至此,我们就得到了用于蒸馏训练的
<code>
student_program
</code>
,后面就可以使用一个普通program一样对其开始训练和评估。
</p>
</div>
</div>
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录