Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleSlim
提交
c3ad43ef
P
PaddleSlim
项目概览
PaddlePaddle
/
PaddleSlim
1 年多 前同步成功
通知
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看板
提交
c3ad43ef
编写于
12月 04, 2019
作者:
W
wanghaoshuang
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'sensitive' into 'develop'
Simplify arguments of sensitive API. See merge request !67
上级
5ed67bd9
0d04d6bd
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
5 addition
and
12 deletion
+5
-12
paddleslim/prune/sensitive.py
paddleslim/prune/sensitive.py
+5
-12
未找到文件。
paddleslim/prune/sensitive.py
浏览文件 @
c3ad43ef
...
...
@@ -33,12 +33,14 @@ def sensitivity(program,
param_names
,
eval_func
,
sensitivities_file
=
None
,
step_size
=
0.2
,
max_pruned_times
=
None
):
pruned_ratios
=
None
):
scope
=
fluid
.
global_scope
()
graph
=
GraphWrapper
(
program
)
sensitivities
=
_load_sensitivities
(
sensitivities_file
)
if
pruned_ratios
is
None
:
pruned_ratios
=
np
.
arange
(
0.1
,
1
,
step
=
0.1
)
for
name
in
param_names
:
if
name
not
in
sensitivities
:
size
=
graph
.
var
(
name
).
shape
()[
0
]
...
...
@@ -49,16 +51,9 @@ def sensitivity(program,
}
baseline
=
None
for
name
in
sensitivities
:
ratio
=
step_size
pruned_times
=
0
while
ratio
<
1
:
if
max_pruned_times
is
not
None
and
pruned_times
>=
max_pruned_times
:
break
ratio
=
round
(
ratio
,
2
)
for
ratio
in
pruned_ratios
:
if
ratio
in
sensitivities
[
name
][
'pruned_percent'
]:
_logger
.
debug
(
'{}, {} has computed.'
.
format
(
name
,
ratio
))
ratio
+=
step_size
pruned_times
+=
1
continue
if
baseline
is
None
:
baseline
=
eval_func
(
graph
.
program
)
...
...
@@ -92,8 +87,6 @@ def sensitivity(program,
for
param_name
in
param_backup
.
keys
():
param_t
=
scope
.
find_var
(
param_name
).
get_tensor
()
param_t
.
set
(
param_backup
[
param_name
],
place
)
ratio
+=
step_size
pruned_times
+=
1
return
sensitivities
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录