Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleSlim
提交
d00373ae
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看板
未验证
提交
d00373ae
编写于
8月 04, 2020
作者:
B
Bai Yifan
提交者:
GitHub
8月 04, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix pact demo path issue (#403)
上级
a769b284
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
11 addition
and
12 deletion
+11
-12
demo/quant/pact_quant_aware/train.py
demo/quant/pact_quant_aware/train.py
+11
-12
未找到文件。
demo/quant/pact_quant_aware/train.py
浏览文件 @
d00373ae
...
...
@@ -8,8 +8,9 @@ import math
import
time
import
numpy
as
np
import
paddle.fluid
as
fluid
sys
.
path
[
0
]
=
os
.
path
.
join
(
os
.
path
.
dirname
(
"__file__"
),
os
.
path
.
pardir
,
os
.
path
.
pardir
)
sys
.
path
.
append
(
os
.
path
.
dirname
(
"__file__"
))
sys
.
path
.
append
(
os
.
path
.
join
(
os
.
path
.
dirname
(
"__file__"
),
os
.
path
.
pardir
,
os
.
path
.
pardir
))
from
paddleslim.common
import
get_logger
from
paddleslim.analysis
import
flops
from
paddleslim.quant
import
quant_aware
,
quant_post
,
convert
...
...
@@ -133,8 +134,8 @@ def compress(args):
raise
ValueError
(
"{} is not supported."
.
format
(
args
.
data
))
image_shape
=
[
int
(
m
)
for
m
in
image_shape
.
split
(
","
)]
assert
args
.
model
in
model_list
,
"{} is not in lists: {}"
.
format
(
args
.
model
,
model_list
)
assert
args
.
model
in
model_list
,
"{} is not in lists: {}"
.
format
(
args
.
model
,
model_list
)
image
=
fluid
.
layers
.
data
(
name
=
'image'
,
shape
=
image_shape
,
dtype
=
'float32'
)
if
args
.
use_pact
:
image
.
stop_gradient
=
False
...
...
@@ -196,8 +197,7 @@ def compress(args):
if
args
.
pretrained_model
:
def
if_exist
(
var
):
return
os
.
path
.
exists
(
os
.
path
.
join
(
args
.
pretrained_model
,
var
.
name
))
return
os
.
path
.
exists
(
os
.
path
.
join
(
args
.
pretrained_model
,
var
.
name
))
fluid
.
io
.
load_vars
(
exe
,
args
.
pretrained_model
,
predicate
=
if_exist
)
...
...
@@ -230,10 +230,9 @@ def compress(args):
acc_top5_ns
.
append
(
np
.
mean
(
acc_top5_n
))
batch_id
+=
1
_logger
.
info
(
"Final eval epoch[{}] - acc_top1: {}; acc_top5: {}"
.
format
(
epoch
,
np
.
mean
(
np
.
array
(
acc_top1_ns
)),
np
.
mean
(
np
.
array
(
acc_top5_ns
))))
_logger
.
info
(
"Final eval epoch[{}] - acc_top1: {}; acc_top5: {}"
.
format
(
epoch
,
np
.
mean
(
np
.
array
(
acc_top1_ns
)),
np
.
mean
(
np
.
array
(
acc_top5_ns
))))
return
np
.
mean
(
np
.
array
(
acc_top1_ns
))
def
train
(
epoch
,
compiled_train_prog
):
...
...
@@ -259,8 +258,8 @@ def compress(args):
threshold
=
{}
for
var
in
val_program
.
list_vars
():
if
'pact'
in
var
.
name
:
array
=
np
.
array
(
fluid
.
global_scope
().
find_var
(
var
.
name
)
.
get_tensor
())
array
=
np
.
array
(
fluid
.
global_scope
().
find_var
(
var
.
name
)
.
get_tensor
())
threshold
[
var
.
name
]
=
array
[
0
]
print
(
threshold
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录