Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
models
提交
db5f3295
M
models
项目概览
PaddlePaddle
/
models
大约 1 年 前同步成功
通知
222
Star
6828
Fork
2962
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
602
列表
看板
标记
里程碑
合并请求
255
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
M
models
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
602
Issue
602
列表
看板
标记
里程碑
合并请求
255
合并请求
255
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
db5f3295
编写于
10月 15, 2019
作者:
L
Liufang Sang
提交者:
whs
10月 15, 2019
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[PaddleSlim] save infer model for each epoch (#3570)
上级
4f7bf849
变更
5
显示空白变更内容
内联
并排
Showing
5 changed file
with
22 addition
and
9 deletion
+22
-9
PaddleCV/PaddleDetection/slim/quantization/README.md
PaddleCV/PaddleDetection/slim/quantization/README.md
+0
-1
PaddleCV/PaddleDetection/slim/quantization/compress.py
PaddleCV/PaddleDetection/slim/quantization/compress.py
+1
-0
PaddleCV/PaddleDetection/slim/quantization/freeze.py
PaddleCV/PaddleDetection/slim/quantization/freeze.py
+1
-1
PaddleSlim/classification/quantization/compress.py
PaddleSlim/classification/quantization/compress.py
+1
-0
PaddleSlim/classification/quantization/freeze.py
PaddleSlim/classification/quantization/freeze.py
+19
-7
未找到文件。
PaddleCV/PaddleDetection/slim/quantization/README.md
浏览文件 @
db5f3295
...
@@ -44,7 +44,6 @@ step1: 设置gpu卡
...
@@ -44,7 +44,6 @@ step1: 设置gpu卡
export CUDA_VISIBLE_DEVICES=0
export CUDA_VISIBLE_DEVICES=0
```
```
step2: 开始训练
step2: 开始训练
```
使用PaddleDetection提供的配置文件在用8卡进行训练:
使用PaddleDetection提供的配置文件在用8卡进行训练:
```
```
...
...
PaddleCV/PaddleDetection/slim/quantization/compress.py
浏览文件 @
db5f3295
...
@@ -239,6 +239,7 @@ def main():
...
@@ -239,6 +239,7 @@ def main():
eval_feed_list
=
test_feed
,
eval_feed_list
=
test_feed
,
eval_func
=
{
'map'
:
eval_func
},
eval_func
=
{
'map'
:
eval_func
},
eval_fetch_list
=
[
eval_fetch_list
[
0
]],
eval_fetch_list
=
[
eval_fetch_list
[
0
]],
prune_infer_model
=
[[
"image"
,
"im_size"
],[
"multiclass_nms_0.tmp_0"
]],
train_optimizer
=
None
)
train_optimizer
=
None
)
com
.
config
(
FLAGS
.
slim_file
)
com
.
config
(
FLAGS
.
slim_file
)
com
.
run
()
com
.
run
()
...
...
PaddleCV/PaddleDetection/slim/quantization/freeze.py
浏览文件 @
db5f3295
...
@@ -142,7 +142,7 @@ def main():
...
@@ -142,7 +142,7 @@ def main():
assert
os
.
path
.
exists
(
FLAGS
.
model_path
)
assert
os
.
path
.
exists
(
FLAGS
.
model_path
)
infer_prog
,
feed_names
,
fetch_targets
=
fluid
.
io
.
load_inference_model
(
infer_prog
,
feed_names
,
fetch_targets
=
fluid
.
io
.
load_inference_model
(
dirname
=
FLAGS
.
model_path
,
executor
=
exe
,
dirname
=
FLAGS
.
model_path
,
executor
=
exe
,
model_filename
=
'__model__'
,
model_filename
=
'__model__
.infer
'
,
params_filename
=
'__params__'
)
params_filename
=
'__params__'
)
eval_keys
=
[
'bbox'
,
'gt_box'
,
'gt_label'
,
'is_difficult'
]
eval_keys
=
[
'bbox'
,
'gt_box'
,
'gt_label'
,
'is_difficult'
]
...
...
PaddleSlim/classification/quantization/compress.py
浏览文件 @
db5f3295
...
@@ -95,6 +95,7 @@ def compress(args):
...
@@ -95,6 +95,7 @@ def compress(args):
eval_fetch_list
=
val_fetch_list
,
eval_fetch_list
=
val_fetch_list
,
teacher_programs
=
[],
teacher_programs
=
[],
train_optimizer
=
opt
,
train_optimizer
=
opt
,
prune_infer_model
=
[[
image
.
name
],
[
out
.
name
]],
distiller_optimizer
=
None
)
distiller_optimizer
=
None
)
com_pass
.
config
(
args
.
config_file
)
com_pass
.
config
(
args
.
config_file
)
com_pass
.
run
()
com_pass
.
run
()
...
...
PaddleSlim/classification/quantization/freeze.py
浏览文件 @
db5f3295
...
@@ -53,20 +53,32 @@ def eval(args):
...
@@ -53,20 +53,32 @@ def eval(args):
val_program
,
feed_names
,
fetch_targets
=
fluid
.
io
.
load_inference_model
(
args
.
model_path
,
val_program
,
feed_names
,
fetch_targets
=
fluid
.
io
.
load_inference_model
(
args
.
model_path
,
exe
,
exe
,
model_filename
=
"__model__"
,
model_filename
=
"__model__
.infer
"
,
params_filename
=
"__params__"
)
params_filename
=
"__params__"
)
val_reader
=
paddle
.
batch
(
reader
.
val
(),
batch_size
=
128
)
val_reader
=
paddle
.
batch
(
reader
.
val
(),
batch_size
=
128
)
feeder
=
fluid
.
DataFeeder
(
place
=
place
,
feed_list
=
feed_names
,
program
=
val_program
)
feeder
=
fluid
.
DataFeeder
(
place
=
place
,
feed_list
=
feed_names
,
program
=
val_program
)
results
=
[]
results
=
[]
for
batch_id
,
data
in
enumerate
(
val_reader
()):
for
batch_id
,
data
in
enumerate
(
val_reader
()):
image
=
[[
d
[
0
]]
for
d
in
data
]
# top1_acc, top5_acc
label
=
[[
d
[
1
]]
for
d
in
data
]
result
=
exe
.
run
(
val_program
,
feed_data
=
feeder
.
feed
(
image
)
feed
=
feeder
.
feed
(
data
),
pred
=
exe
.
run
(
val_program
,
feed
=
feed_data
,
fetch_list
=
fetch_targets
)
fetch_list
=
fetch_targets
)
result
=
[
np
.
mean
(
r
)
for
r
in
result
]
pred
=
np
.
array
(
pred
[
0
])
results
.
append
(
result
)
label
=
np
.
array
(
label
)
sort_array
=
pred
.
argsort
(
axis
=
1
)
top_1_pred
=
sort_array
[:,
-
1
:][:,
::
-
1
]
top_1
=
np
.
mean
(
label
==
top_1_pred
)
top_5_pred
=
sort_array
[:,
-
5
:][:,
::
-
1
]
acc_num
=
0
for
i
in
range
(
len
(
label
)):
if
label
[
i
][
0
]
in
top_5_pred
[
i
]:
acc_num
+=
1
top_5
=
acc_num
/
len
(
label
)
results
.
append
([
top_1
,
top_5
])
result
=
np
.
mean
(
np
.
array
(
results
),
axis
=
0
)
result
=
np
.
mean
(
np
.
array
(
results
),
axis
=
0
)
print
(
"top1_acc/top5_acc= {}"
.
format
(
result
))
print
(
"top1_acc/top5_acc= {}"
.
format
(
result
))
sys
.
stdout
.
flush
()
sys
.
stdout
.
flush
()
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录