Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleSlim
提交
f3fcd836
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看板
未验证
提交
f3fcd836
编写于
4月 23, 2020
作者:
W
whs
提交者:
GitHub
4月 23, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix visiting strategy while pruning network (#235)
上级
5b3bd165
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
5 addition
and
5 deletion
+5
-5
paddleslim/prune/group_param.py
paddleslim/prune/group_param.py
+1
-2
paddleslim/prune/pruner.py
paddleslim/prune/pruner.py
+4
-3
未找到文件。
paddleslim/prune/group_param.py
浏览文件 @
f3fcd836
...
...
@@ -19,7 +19,7 @@ from .prune_walker import conv2d as conv2d_walker
__all__
=
[
"collect_convs"
]
def
collect_convs
(
params
,
graph
):
def
collect_convs
(
params
,
graph
,
visited
=
{}
):
"""Collect convolution layers of graph into groups. The layers in the same group is relative on pruning operation.
A group is a list of tuple with format (param_name, axis) in which `param_name` is the name of parameter and `axis` is the axis to be pruned on.
...
...
@@ -52,7 +52,6 @@ def collect_convs(params, graph):
graph
=
GraphWrapper
(
graph
)
groups
=
[]
for
param
in
params
:
visited
=
{}
pruned_params
=
[]
param
=
graph
.
var
(
param
)
conv_op
=
param
.
outputs
()[
0
]
...
...
paddleslim/prune/pruner.py
浏览文件 @
f3fcd836
...
...
@@ -90,7 +90,7 @@ class Pruner():
visited
=
{}
pruned_params
=
[]
for
param
,
ratio
in
zip
(
params
,
ratios
):
group
=
collect_convs
([
param
],
graph
)[
0
]
# [(name, axis)]
group
=
collect_convs
([
param
],
graph
,
visited
)[
0
]
# [(name, axis)]
if
only_graph
and
self
.
idx_selector
.
__name__
==
"default_idx_selector"
:
param_v
=
graph
.
var
(
param
)
...
...
@@ -126,8 +126,9 @@ class Pruner():
pruned_axis
])
param
=
graph
.
var
(
param_name
)
if
not
lazy
:
_logger
.
debug
(
"{}
\t
{}
\t
{}"
.
format
(
param
.
name
(
),
pruned_axis
,
len
(
pruned_idx
)))
_logger
.
debug
(
"{}
\t
{}
\t
{}
\t
{}"
.
format
(
param
.
name
(),
pruned_axis
,
param
.
shape
()[
pruned_axis
],
len
(
pruned_idx
)))
if
param_shape_backup
is
not
None
:
origin_shape
=
copy
.
deepcopy
(
param
.
shape
())
param_shape_backup
[
param
.
name
()]
=
origin_shape
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录