Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Crayon鑫
Paddle
提交
486f7d8e
P
Paddle
项目概览
Crayon鑫
/
Paddle
与 Fork 源项目一致
Fork自
PaddlePaddle / Paddle
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
486f7d8e
编写于
4月 18, 2019
作者:
W
whs
提交者:
GitHub
4月 18, 2019
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Restore quantization and distillation stategy before loading persistables. (#16958)
test=develop
上级
8bcba3db
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
11 addition
and
6 deletion
+11
-6
python/paddle/fluid/contrib/slim/core/compressor.py
python/paddle/fluid/contrib/slim/core/compressor.py
+3
-0
python/paddle/fluid/contrib/slim/core/strategy.py
python/paddle/fluid/contrib/slim/core/strategy.py
+3
-0
python/paddle/fluid/contrib/slim/distillation/distillation_strategy.py
.../fluid/contrib/slim/distillation/distillation_strategy.py
+1
-1
python/paddle/fluid/contrib/slim/quantization/quantization_strategy.py
.../fluid/contrib/slim/quantization/quantization_strategy.py
+4
-5
未找到文件。
python/paddle/fluid/contrib/slim/core/compressor.py
浏览文件 @
486f7d8e
...
...
@@ -363,6 +363,9 @@ class Compressor(object):
strategies
=
pickle
.
load
(
strategy_file
,
encoding
=
'bytes'
)
for
strategy
in
strategies
:
strategy
.
restore_from_checkpoint
(
context
)
if
os
.
path
.
exists
(
model_path
):
exe
=
SlimGraphExecutor
(
context
.
place
)
with
scope_guard
(
context
.
scope
):
...
...
python/paddle/fluid/contrib/slim/core/strategy.py
浏览文件 @
486f7d8e
...
...
@@ -46,3 +46,6 @@ class Strategy(object):
def
on_compression_end
(
self
,
context
):
pass
def
restore_from_checkpoint
(
self
,
context
):
pass
python/paddle/fluid/contrib/slim/distillation/distillation_strategy.py
浏览文件 @
486f7d8e
...
...
@@ -38,7 +38,7 @@ class DistillationStrategy(Strategy):
super
(
DistillationStrategy
,
self
).
__init__
(
start_epoch
,
end_epoch
)
self
.
distillers
=
distillers
def
on_compression_begin
(
self
,
context
):
def
restore_from_checkpoint
(
self
,
context
):
# load from checkpoint
if
context
.
epoch_id
>
0
:
if
context
.
epoch_id
>
self
.
start_epoch
and
context
.
epoch_id
<
self
.
end_epoch
:
...
...
python/paddle/fluid/contrib/slim/quantization/quantization_strategy.py
浏览文件 @
486f7d8e
...
...
@@ -88,7 +88,7 @@ class QuantizationStrategy(Strategy):
self
.
save_out_nodes
=
save_out_nodes
self
.
save_in_nodes
=
save_in_nodes
def
on_compression_begin
(
self
,
context
):
def
restore_from_checkpoint
(
self
,
context
):
"""
Restore graph when the compressoin task is inited from checkpoint.
"""
...
...
@@ -143,10 +143,9 @@ class QuantizationStrategy(Strategy):
train_ir_graph
.
graph
).
with_data_parallel
(
loss_name
=
context
.
optimize_graph
.
out_nodes
[
'loss'
],
build_strategy
=
build_strategy
)
# for evaluation. And program compiled from ir graph must be with data parallel.
context
.
eval_graph
.
compiled_graph
=
CompiledProgram
(
test_ir_graph
.
graph
).
with_data_parallel
(
build_strategy
=
build_strategy
)
context
.
eval_graph
.
program
=
test_ir_graph
.
to_program
()
# for saving inference model after training
context
.
put
(
'quantization_test_ir_graph_backup'
,
test_ir_graph
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录