Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleSlim
提交
da4c6757
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看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
da4c6757
编写于
12月 01, 2020
作者:
B
Bai Yifan
提交者:
GitHub
12月 01, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix pact demo dataloader (#526)
* fix bug * code fix
上级
3d2a5924
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
17 addition
and
20 deletion
+17
-20
demo/quant/pact_quant_aware/train.py
demo/quant/pact_quant_aware/train.py
+14
-17
demo/quant/quant_aware/train.py
demo/quant/quant_aware/train.py
+3
-3
未找到文件。
demo/quant/pact_quant_aware/train.py
浏览文件 @
da4c6757
...
...
@@ -157,7 +157,9 @@ def compress(args):
places
=
places
,
feed_list
=
[
image
,
label
],
drop_last
=
True
,
return_list
=
False
,
batch_size
=
args
.
batch_size
,
use_shared_memory
=
False
,
shuffle
=
True
,
num_workers
=
1
)
...
...
@@ -166,7 +168,9 @@ def compress(args):
places
=
place
,
feed_list
=
[
image
,
label
],
drop_last
=
False
,
return_list
=
False
,
batch_size
=
args
.
batch_size
,
use_shared_memory
=
False
,
shuffle
=
False
)
if
args
.
analysis
:
...
...
@@ -372,13 +376,8 @@ def compress(args):
ckpt_path
=
args
.
checkpoint_dir
assert
args
.
checkpoint_epoch
is
not
None
,
"checkpoint_epoch must be set"
start_epoch
=
args
.
checkpoint_epoch
paddle
.
static
.
load_vars
(
exe
,
dirname
=
args
.
checkpoint_dir
,
main_program
=
val_program
)
start_step
=
start_epoch
*
int
(
math
.
ceil
(
float
(
args
.
total_images
)
/
args
.
batch_size
))
v
=
paddle
.
static
.
global_scope
().
find_var
(
'@LR_DECAY_COUNTER@'
).
get_tensor
()
v
.
set
(
np
.
array
([
start_step
]).
astype
(
np
.
float32
),
place
)
paddle
.
static
.
load
(
executor
=
exe
,
model_path
=
args
.
checkpoint_dir
,
program
=
val_program
)
best_eval_acc1
=
0
best_acc1_epoch
=
0
...
...
@@ -391,22 +390,20 @@ def compress(args):
_logger
.
info
(
"Best Validation Acc1: {:.6f}, at epoch {}"
.
format
(
best_eval_acc1
,
best_acc1_epoch
))
paddle
.
static
.
save
(
exe
,
dirname
=
os
.
path
.
join
(
args
.
output_dir
,
str
(
i
)),
main_program
=
val_program
)
model_path
=
os
.
path
.
join
(
args
.
output_dir
,
str
(
i
)),
program
=
val_program
)
if
acc1
>
best_acc1
:
best_acc1
=
acc1
best_epoch
=
i
paddle
.
static
.
save
(
exe
,
dirname
=
os
.
path
.
join
(
args
.
output_dir
,
'best_model'
),
main_program
=
val_program
)
model_path
=
os
.
path
.
join
(
args
.
output_dir
,
'best_model'
),
program
=
val_program
)
if
os
.
path
.
exists
(
os
.
path
.
join
(
args
.
output_dir
,
'best_model'
)):
if
os
.
path
.
exists
(
os
.
path
.
join
(
args
.
output_dir
,
'best_model
.pdparams
'
)):
paddle
.
static
.
load
(
exe
,
dirname
=
os
.
path
.
join
(
args
.
output_dir
,
'best_model'
),
main_
program
=
val_program
)
exe
cutor
=
exe
,
model_path
=
os
.
path
.
join
(
args
.
output_dir
,
'best_model'
),
program
=
val_program
)
# 3. Freeze the graph after training by adjusting the quantize
# operators' order for the inference.
...
...
demo/quant/quant_aware/train.py
浏览文件 @
da4c6757
...
...
@@ -256,9 +256,9 @@ def compress(args):
model_path
=
os
.
path
.
join
(
args
.
checkpoint_dir
,
'best_model'
))
if
os
.
path
.
exists
(
os
.
path
.
join
(
args
.
checkpoint_dir
,
'best_model'
)):
paddle
.
static
.
load
(
exe
,
dirname
=
os
.
path
.
join
(
args
.
checkpoint_dir
,
'best_model'
),
main_
program
=
val_program
)
exe
cutor
=
exe
,
model_path
=
os
.
path
.
join
(
args
.
checkpoint_dir
,
'best_model'
),
program
=
val_program
)
############################################################################################################
# 3. Freeze the graph after training by adjusting the quantize
# operators' order for the inference.
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录