Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
4836ee68
P
Paddle
项目概览
PaddlePaddle
/
Paddle
大约 1 年 前同步成功
通知
2298
Star
20931
Fork
5422
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1423
列表
看板
标记
里程碑
合并请求
543
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1,423
Issue
1,423
列表
看板
标记
里程碑
合并请求
543
合并请求
543
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
4836ee68
编写于
9月 23, 2019
作者:
G
Ghost Under Moon
提交者:
hong
9月 23, 2019
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
warning when user save a inference model which contains auc op test=develop (#19838)
上级
5452b6a1
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
38 addition
and
0 deletion
+38
-0
python/paddle/fluid/io.py
python/paddle/fluid/io.py
+9
-0
python/paddle/fluid/tests/unittests/test_inference_model_io.py
...n/paddle/fluid/tests/unittests/test_inference_model_io.py
+29
-0
未找到文件。
python/paddle/fluid/io.py
浏览文件 @
4836ee68
...
...
@@ -1031,6 +1031,15 @@ def save_inference_model(dirname,
main_program
=
_get_valid_program
(
main_program
)
# remind user to set auc_states to zeros if the program contains auc op
all_ops
=
main_program
.
global_block
().
ops
for
op
in
all_ops
:
if
op
.
type
==
'auc'
:
warnings
.
warn
(
"please ensure that you have set the auc states to zeros before saving inference model"
)
break
# fix the bug that the activation op's output as target will be pruned.
# will affect the inference performance.
# TODO(Superjomn) add an IR pass to remove 1-scale op.
...
...
python/paddle/fluid/tests/unittests/test_inference_model_io.py
浏览文件 @
4836ee68
...
...
@@ -19,6 +19,8 @@ import unittest
import
six
import
numpy
as
np
import
paddle.fluid.core
as
core
import
paddle.fluid
as
fluid
import
warnings
import
paddle.fluid.executor
as
executor
import
paddle.fluid.layers
as
layers
...
...
@@ -111,6 +113,33 @@ class TestSaveInferenceModel(unittest.TestCase):
save_inference_model
(
MODEL_DIR
,
[
"x"
,
"y"
],
[
avg_cost
],
exe
,
program
)
def
test_save_inference_model_with_auc
(
self
):
MODEL_DIR
=
"./tmp/inference_model4"
init_program
=
Program
()
program
=
Program
()
# fake program without feed/fetch
with
program_guard
(
program
,
init_program
):
x
=
layers
.
data
(
name
=
'x'
,
shape
=
[
2
],
dtype
=
'float32'
)
y
=
layers
.
data
(
name
=
'y'
,
shape
=
[
1
],
dtype
=
'float32'
)
predict
=
fluid
.
layers
.
fc
(
input
=
x
,
size
=
2
,
act
=
'softmax'
)
acc
=
fluid
.
layers
.
accuracy
(
input
=
predict
,
label
=
y
)
auc_var
,
batch_auc_var
,
auc_states
=
fluid
.
layers
.
auc
(
input
=
predict
,
label
=
y
)
cost
=
fluid
.
layers
.
cross_entropy
(
input
=
predict
,
label
=
y
)
avg_cost
=
fluid
.
layers
.
mean
(
x
=
cost
)
place
=
core
.
CPUPlace
()
exe
=
executor
.
Executor
(
place
)
exe
.
run
(
init_program
,
feed
=
{},
fetch_list
=
[])
with
warnings
.
catch_warnings
(
record
=
True
)
as
w
:
warnings
.
simplefilter
(
"always"
)
save_inference_model
(
MODEL_DIR
,
[
"x"
,
"y"
],
[
avg_cost
],
exe
,
program
)
expected_warn
=
"please ensure that you have set the auc states to zeros before saving inference model"
self
.
assertTrue
(
len
(
w
)
>
0
)
self
.
assertTrue
(
expected_warn
==
str
(
w
[
0
].
message
))
class
TestInstance
(
unittest
.
TestCase
):
def
test_save_inference_model
(
self
):
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录