Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
models
提交
306ece7f
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看板
未验证
提交
306ece7f
编写于
2月 28, 2019
作者:
Y
Yibing Liu
提交者:
GitHub
2月 28, 2019
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix dam test bug & add eval metrics in result file (#1803)
上级
f5382bbb
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
5 addition
and
4 deletion
+5
-4
fluid/PaddleNLP/deep_attention_matching_net/test_and_evaluate.py
...addleNLP/deep_attention_matching_net/test_and_evaluate.py
+5
-4
未找到文件。
fluid/PaddleNLP/deep_attention_matching_net/test_and_evaluate.py
浏览文件 @
306ece7f
...
@@ -130,13 +130,13 @@ def test(args):
...
@@ -130,13 +130,13 @@ def test(args):
loss
,
logits
=
dam
.
create_network
()
loss
,
logits
=
dam
.
create_network
()
loss
.
persistable
=
True
loss
.
persistable
=
True
logits
.
persistable
=
True
# gradient clipping
# gradient clipping
fluid
.
clip
.
set_gradient_clip
(
clip
=
fluid
.
clip
.
GradientClipByValue
(
fluid
.
clip
.
set_gradient_clip
(
clip
=
fluid
.
clip
.
GradientClipByValue
(
max
=
1.0
,
min
=-
1.0
))
max
=
1.0
,
min
=-
1.0
))
test_program
=
fluid
.
default_main_program
().
clone
(
for_test
=
True
)
test_program
=
fluid
.
default_main_program
().
clone
(
for_test
=
True
)
optimizer
=
fluid
.
optimizer
.
Adam
(
optimizer
=
fluid
.
optimizer
.
Adam
(
learning_rate
=
fluid
.
layers
.
exponential_decay
(
learning_rate
=
fluid
.
layers
.
exponential_decay
(
learning_rate
=
args
.
learning_rate
,
learning_rate
=
args
.
learning_rate
,
...
@@ -145,7 +145,6 @@ def test(args):
...
@@ -145,7 +145,6 @@ def test(args):
staircase
=
True
))
staircase
=
True
))
optimizer
.
minimize
(
loss
)
optimizer
.
minimize
(
loss
)
# The fethced loss is wrong when mem opt is enabled
fluid
.
memory_optimize
(
fluid
.
default_main_program
())
fluid
.
memory_optimize
(
fluid
.
default_main_program
())
if
args
.
use_cuda
:
if
args
.
use_cuda
:
...
@@ -173,8 +172,10 @@ def test(args):
...
@@ -173,8 +172,10 @@ def test(args):
if
args
.
ext_eval
:
if
args
.
ext_eval
:
import
utils.douban_evaluation
as
eva
import
utils.douban_evaluation
as
eva
eval_metrics
=
[
"MAP"
,
"MRR"
,
"P@1"
,
"R_{10}@1"
,
"R_{10}@2"
,
"R_{10}@5"
]
else
:
else
:
import
utils.evaluation
as
eva
import
utils.evaluation
as
eva
eval_metrics
=
[
"R_2@1"
,
"R_{10}@1"
,
"R_{10}@2"
,
"R_{10}@5"
]
test_batches
=
reader
.
build_batches
(
test_data
,
data_conf
)
test_batches
=
reader
.
build_batches
(
test_data
,
data_conf
)
...
@@ -214,8 +215,8 @@ def test(args):
...
@@ -214,8 +215,8 @@ def test(args):
result
=
eva
.
evaluate
(
score_path
)
result
=
eva
.
evaluate
(
score_path
)
result_file_path
=
os
.
path
.
join
(
args
.
save_path
,
'result.txt'
)
result_file_path
=
os
.
path
.
join
(
args
.
save_path
,
'result.txt'
)
with
open
(
result_file_path
,
'w'
)
as
out_file
:
with
open
(
result_file_path
,
'w'
)
as
out_file
:
for
p_at
in
result
:
for
metric
,
p_at
in
zip
(
eval_metrics
,
result
)
:
out_file
.
write
(
str
(
p_at
)
+
'
\n
'
)
out_file
.
write
(
metric
+
": "
+
str
(
p_at
)
+
'
\n
'
)
print
(
'finish test'
)
print
(
'finish test'
)
print
(
time
.
strftime
(
'%Y-%m-%d %H:%M:%S'
,
time
.
localtime
(
time
.
time
())))
print
(
time
.
strftime
(
'%Y-%m-%d %H:%M:%S'
,
time
.
localtime
(
time
.
time
())))
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录