Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleSlim
提交
3d2a5924
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看板
未验证
提交
3d2a5924
编写于
11月 26, 2020
作者:
B
Bai Yifan
提交者:
GitHub
11月 26, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix save/load_inference_model, dataloader (#523)
* fix dataloader
上级
1a54970a
变更
12
隐藏空白更改
内联
并排
Showing
12 changed file
with
41 addition
and
13 deletion
+41
-13
demo/distillation/distill.py
demo/distillation/distill.py
+3
-1
demo/prune/eval.py
demo/prune/eval.py
+1
-0
demo/prune/train.py
demo/prune/train.py
+2
-0
demo/quant/pact_quant_aware/train.py
demo/quant/pact_quant_aware/train.py
+1
-1
demo/quant/quant_aware/train.py
demo/quant/quant_aware/train.py
+3
-1
demo/quant/quant_post/eval.py
demo/quant/quant_post/eval.py
+1
-1
demo/quant/quant_post/export_model.py
demo/quant/quant_post/export_model.py
+1
-1
tests/test_analysis_helper.py
tests/test_analysis_helper.py
+1
-0
tests/test_quant_aware.py
tests/test_quant_aware.py
+6
-1
tests/test_quant_aware_user_defined.py
tests/test_quant_aware_user_defined.py
+6
-1
tests/test_quant_post.py
tests/test_quant_post.py
+8
-3
tests/test_quant_post_only_weight.py
tests/test_quant_post_only_weight.py
+8
-3
未找到文件。
demo/distillation/distill.py
浏览文件 @
3d2a5924
...
...
@@ -121,6 +121,7 @@ def compress(args):
feed_list
=
[
image
,
label
],
drop_last
=
True
,
batch_size
=
args
.
batch_size
,
return_list
=
False
,
shuffle
=
True
,
use_shared_memory
=
False
,
num_workers
=
1
)
...
...
@@ -129,6 +130,7 @@ def compress(args):
places
=
place
,
feed_list
=
[
image
,
label
],
drop_last
=
False
,
return_list
=
False
,
use_shared_memory
=
False
,
batch_size
=
args
.
batch_size
,
shuffle
=
False
)
...
...
@@ -217,7 +219,7 @@ def compress(args):
format
(
epoch_id
,
step_id
,
val_loss
[
0
],
val_acc1
[
0
],
val_acc5
[
0
]))
if
args
.
save_inference
:
paddle
.
static
.
save_inference_model
(
paddle
.
fluid
.
io
.
save_inference_model
(
os
.
path
.
join
(
"./saved_models"
,
str
(
epoch_id
)),
[
"image"
],
[
out
],
exe
,
student_program
)
_logger
.
info
(
"epoch {} top1 {:.6f}, top5 {:.6f}"
.
format
(
...
...
demo/prune/eval.py
浏览文件 @
3d2a5924
...
...
@@ -65,6 +65,7 @@ def eval(args):
places
=
place
,
feed_list
=
[
image
,
label
],
drop_last
=
False
,
return_list
=
False
,
batch_size
=
args
.
batch_size
,
shuffle
=
False
)
...
...
demo/prune/train.py
浏览文件 @
3d2a5924
...
...
@@ -150,6 +150,7 @@ def compress(args):
drop_last
=
True
,
batch_size
=
args
.
batch_size
,
shuffle
=
True
,
return_list
=
False
,
use_shared_memory
=
False
,
num_workers
=
16
)
valid_loader
=
paddle
.
io
.
DataLoader
(
...
...
@@ -157,6 +158,7 @@ def compress(args):
places
=
place
,
feed_list
=
[
image
,
label
],
drop_last
=
False
,
return_list
=
False
,
use_shared_memory
=
False
,
batch_size
=
args
.
batch_size
,
shuffle
=
False
)
...
...
demo/quant/pact_quant_aware/train.py
浏览文件 @
3d2a5924
...
...
@@ -426,7 +426,7 @@ def compress(args):
if
not
os
.
path
.
isdir
(
model_path
):
os
.
makedirs
(
model_path
)
paddle
.
static
.
save_inference_model
(
paddle
.
fluid
.
io
.
save_inference_model
(
dirname
=
float_path
,
feeded_var_names
=
[
image
.
name
],
target_vars
=
[
out
],
...
...
demo/quant/quant_aware/train.py
浏览文件 @
3d2a5924
...
...
@@ -168,6 +168,7 @@ def compress(args):
feed_list
=
[
image
,
label
],
drop_last
=
True
,
batch_size
=
args
.
batch_size
,
return_list
=
False
,
use_shared_memory
=
False
,
shuffle
=
True
,
num_workers
=
1
)
...
...
@@ -176,6 +177,7 @@ 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
)
...
...
@@ -277,7 +279,7 @@ def compress(args):
if
not
os
.
path
.
isdir
(
model_path
):
os
.
makedirs
(
model_path
)
paddle
.
static
.
save_inference_model
(
paddle
.
fluid
.
io
.
save_inference_model
(
dirname
=
float_path
,
feeded_var_names
=
[
image
.
name
],
target_vars
=
[
out
],
...
...
demo/quant/quant_post/eval.py
浏览文件 @
3d2a5924
...
...
@@ -40,7 +40,7 @@ def eval(args):
place
=
paddle
.
CUDAPlace
(
0
)
if
args
.
use_gpu
else
paddle
.
CPUPlace
()
exe
=
paddle
.
static
.
Executor
(
place
)
val_program
,
feed_target_names
,
fetch_targets
=
paddle
.
static
.
load_inference_model
(
val_program
,
feed_target_names
,
fetch_targets
=
paddle
.
fluid
.
io
.
load_inference_model
(
args
.
model_path
,
exe
,
model_filename
=
args
.
model_name
,
...
...
demo/quant/quant_post/export_model.py
浏览文件 @
3d2a5924
...
...
@@ -62,7 +62,7 @@ def export_model(args):
else
:
assert
False
,
"args.pretrained_model must set"
paddle
.
static
.
save_inference_model
(
paddle
.
fluid
.
io
.
save_inference_model
(
'./inference_model/'
+
args
.
model
,
feeded_var_names
=
[
image
.
name
],
target_vars
=
[
out
],
...
...
tests/test_analysis_helper.py
浏览文件 @
3d2a5924
...
...
@@ -56,6 +56,7 @@ class TestAnalysisHelper(StaticCase):
places
=
places
,
feed_list
=
[
image
,
label
],
drop_last
=
True
,
return_list
=
False
,
batch_size
=
64
)
exe
.
run
(
paddle
.
static
.
default_startup_program
())
...
...
tests/test_quant_aware.py
浏览文件 @
3d2a5924
...
...
@@ -124,9 +124,14 @@ class TestQuantAwareCase2(StaticCase):
places
=
place
,
feed_list
=
[
image
,
label
],
drop_last
=
True
,
return_list
=
False
,
batch_size
=
64
)
valid_loader
=
paddle
.
io
.
DataLoader
(
test_dataset
,
places
=
place
,
feed_list
=
[
image
,
label
],
batch_size
=
64
)
test_dataset
,
places
=
place
,
feed_list
=
[
image
,
label
],
batch_size
=
64
,
return_list
=
False
)
def
train
(
program
):
iter
=
0
...
...
tests/test_quant_aware_user_defined.py
浏览文件 @
3d2a5924
...
...
@@ -96,9 +96,14 @@ class TestQuantAwareCase1(StaticCase):
places
=
place
,
feed_list
=
[
image
,
label
],
drop_last
=
True
,
return_list
=
False
,
batch_size
=
64
)
valid_loader
=
paddle
.
io
.
DataLoader
(
test_dataset
,
places
=
place
,
feed_list
=
[
image
,
label
],
batch_size
=
64
)
test_dataset
,
places
=
place
,
feed_list
=
[
image
,
label
],
batch_size
=
64
,
return_list
=
False
)
def
train
(
program
):
iter
=
0
...
...
tests/test_quant_post.py
浏览文件 @
3d2a5924
...
...
@@ -60,9 +60,14 @@ class TestQuantAwareCase1(StaticCase):
places
=
place
,
feed_list
=
[
image
,
label
],
drop_last
=
True
,
return_list
=
False
,
batch_size
=
64
)
valid_loader
=
paddle
.
io
.
DataLoader
(
test_dataset
,
places
=
place
,
feed_list
=
[
image
,
label
],
batch_size
=
64
)
test_dataset
,
places
=
place
,
feed_list
=
[
image
,
label
],
batch_size
=
64
,
return_list
=
False
)
def
train
(
program
):
iter
=
0
...
...
@@ -97,7 +102,7 @@ class TestQuantAwareCase1(StaticCase):
train
(
main_prog
)
top1_1
,
top5_1
=
test
(
val_prog
)
paddle
.
static
.
save_inference_model
(
paddle
.
fluid
.
io
.
save_inference_model
(
dirname
=
'./test_quant_post'
,
feeded_var_names
=
[
image
.
name
,
label
.
name
],
target_vars
=
[
avg_cost
,
acc_top1
,
acc_top5
],
...
...
@@ -114,7 +119,7 @@ class TestQuantAwareCase1(StaticCase):
model_filename
=
'model'
,
params_filename
=
'params'
,
batch_nums
=
10
)
quant_post_prog
,
feed_target_names
,
fetch_targets
=
paddle
.
static
.
load_inference_model
(
quant_post_prog
,
feed_target_names
,
fetch_targets
=
paddle
.
fluid
.
io
.
load_inference_model
(
dirname
=
'./test_quant_post_inference'
,
executor
=
exe
,
model_filename
=
'__model__'
,
...
...
tests/test_quant_post_only_weight.py
浏览文件 @
3d2a5924
...
...
@@ -60,9 +60,14 @@ class TestQuantPostOnlyWeightCase1(StaticCase):
places
=
place
,
feed_list
=
[
image
,
label
],
drop_last
=
True
,
return_list
=
False
,
batch_size
=
64
)
valid_loader
=
paddle
.
io
.
DataLoader
(
test_dataset
,
places
=
place
,
feed_list
=
[
image
,
label
],
batch_size
=
64
)
test_dataset
,
places
=
place
,
feed_list
=
[
image
,
label
],
batch_size
=
64
,
return_list
=
False
)
def
train
(
program
):
iter
=
0
...
...
@@ -97,7 +102,7 @@ class TestQuantPostOnlyWeightCase1(StaticCase):
train
(
main_prog
)
top1_1
,
top5_1
=
test
(
val_prog
)
paddle
.
static
.
save_inference_model
(
paddle
.
fluid
.
io
.
save_inference_model
(
dirname
=
'./test_quant_post_dynamic'
,
feeded_var_names
=
[
image
.
name
,
label
.
name
],
target_vars
=
[
avg_cost
,
acc_top1
,
acc_top5
],
...
...
@@ -112,7 +117,7 @@ class TestQuantPostOnlyWeightCase1(StaticCase):
model_filename
=
'model'
,
params_filename
=
'params'
,
generate_test_model
=
True
)
quant_post_prog
,
feed_target_names
,
fetch_targets
=
paddle
.
static
.
load_inference_model
(
quant_post_prog
,
feed_target_names
,
fetch_targets
=
paddle
.
fluid
.
io
.
load_inference_model
(
dirname
=
'./test_quant_post_inference/test_model'
,
executor
=
exe
)
top1_2
,
top5_2
=
test
(
quant_post_prog
,
fetch_targets
)
print
(
"before quantization: top1: {}, top5: {}"
.
format
(
top1_1
,
top5_1
))
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录