Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PALM
提交
092afb6c
P
PALM
项目概览
PaddlePaddle
/
PALM
通知
5
Star
3
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
10
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
PALM
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
10
Issue
10
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
092afb6c
编写于
2月 16, 2020
作者:
X
Xiaoyao Xi
提交者:
GitHub
2月 16, 2020
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #57 from wangxiao1021/api
fix bugs
上级
632de7af
682bede3
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
7 addition
and
2 deletion
+7
-2
paddlepalm/head/mrc.py
paddlepalm/head/mrc.py
+4
-1
paddlepalm/utils/reader_helper.py
paddlepalm/utils/reader_helper.py
+3
-1
未找到文件。
paddlepalm/head/mrc.py
浏览文件 @
092afb6c
...
@@ -337,7 +337,7 @@ def _write_predictions(all_examples, all_features, all_results, n_best_size,
...
@@ -337,7 +337,7 @@ def _write_predictions(all_examples, all_features, all_results, n_best_size,
nbest_json
=
[]
nbest_json
=
[]
for
(
i
,
entry
)
in
enumerate
(
nbest
):
for
(
i
,
entry
)
in
enumerate
(
nbest
):
output
=
collections
.
OrderedDict
()
output
=
collections
.
OrderedDict
()
output
[
"text"
]
=
entry
.
text
output
[
"text"
]
=
entry
.
text
.
encode
(
'utf-8'
).
decode
(
'utf-8'
)
output
[
"probability"
]
=
probs
[
i
]
output
[
"probability"
]
=
probs
[
i
]
output
[
"start_logit"
]
=
entry
.
start_logit
output
[
"start_logit"
]
=
entry
.
start_logit
output
[
"end_logit"
]
=
entry
.
end_logit
output
[
"end_logit"
]
=
entry
.
end_logit
...
@@ -358,8 +358,11 @@ def _write_predictions(all_examples, all_features, all_results, n_best_size,
...
@@ -358,8 +358,11 @@ def _write_predictions(all_examples, all_features, all_results, n_best_size,
all_predictions
[
example
.
qas_id
]
=
best_non_null_entry
.
text
all_predictions
[
example
.
qas_id
]
=
best_non_null_entry
.
text
all_nbest_json
[
example
.
qas_id
]
=
nbest_json
all_nbest_json
[
example
.
qas_id
]
=
nbest_json
with
open
(
output_prediction_file
,
"w"
)
as
writer
:
with
open
(
output_prediction_file
,
"w"
)
as
writer
:
writer
.
write
(
json
.
dumps
(
all_predictions
,
indent
=
4
,
ensure_ascii
=
False
)
+
"
\n
"
)
writer
.
write
(
json
.
dumps
(
all_predictions
,
indent
=
4
,
ensure_ascii
=
False
)
+
"
\n
"
)
with
open
(
output_nbest_file
,
"w"
)
as
writer
:
with
open
(
output_nbest_file
,
"w"
)
as
writer
:
...
...
paddlepalm/utils/reader_helper.py
浏览文件 @
092afb6c
...
@@ -22,6 +22,7 @@ import paddle
...
@@ -22,6 +22,7 @@ import paddle
from
paddle
import
fluid
from
paddle
import
fluid
from
paddle.fluid
import
layers
from
paddle.fluid
import
layers
from
paddlepalm.distribute
import
gpu_dev_count
,
cpu_dev_count
from
paddlepalm.distribute
import
gpu_dev_count
,
cpu_dev_count
import
six
dev_count
=
1
if
gpu_dev_count
<=
1
else
gpu_dev_count
dev_count
=
1
if
gpu_dev_count
<=
1
else
gpu_dev_count
...
@@ -35,7 +36,8 @@ def create_feed_batch_process_fn(net_inputs):
...
@@ -35,7 +36,8 @@ def create_feed_batch_process_fn(net_inputs):
inputs
=
net_inputs
inputs
=
net_inputs
for
q
,
var
in
inputs
.
items
():
for
q
,
var
in
inputs
.
items
():
if
isinstance
(
var
,
str
)
or
isinstance
(
var
,
unicode
):
if
isinstance
(
var
,
str
)
or
(
six
.
PY3
and
isinstance
(
var
,
bytes
))
or
(
six
.
PY2
and
isinstance
(
var
,
unicode
)):
temp
[
var
]
=
data
[
q
]
temp
[
var
]
=
data
[
q
]
else
:
else
:
temp
[
var
.
name
]
=
data
[
q
]
temp
[
var
.
name
]
=
data
[
q
]
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录