Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
models
提交
454de6ce
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看板
提交
454de6ce
编写于
3月 14, 2018
作者:
Y
Yibing Liu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add decoder wrapper to inference
上级
e70b4b35
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
24 addition
and
14 deletion
+24
-14
fluid/DeepASR/data_utils/util.py
fluid/DeepASR/data_utils/util.py
+7
-0
fluid/DeepASR/infer.py
fluid/DeepASR/infer.py
+1
-7
fluid/DeepASR/infer_by_ckpt.py
fluid/DeepASR/infer_by_ckpt.py
+16
-7
未找到文件。
fluid/DeepASR/data_utils/util.py
浏览文件 @
454de6ce
...
...
@@ -50,6 +50,13 @@ def batch_to_ndarray(batch_samples, lod):
return
(
batch_feature
,
batch_label
)
def
split_infer_result
(
infer_seq
,
lod
):
infer_batch
=
[]
for
i
in
xrange
(
0
,
len
(
lod
[
0
])
-
1
):
infer_batch
.
append
(
infer_seq
[
lod
[
0
][
i
]:
lod
[
0
][
i
+
1
]])
return
infer_batch
class
DaemonProcessGroup
(
object
):
def
__init__
(
self
,
proc_num
,
target
,
args
):
self
.
_proc_num
=
proc_num
...
...
fluid/DeepASR/infer.py
浏览文件 @
454de6ce
...
...
@@ -10,6 +10,7 @@ import data_utils.augmentor.trans_add_delta as trans_add_delta
import
data_utils.augmentor.trans_splice
as
trans_splice
import
data_utils.data_reader
as
reader
from
data_utils.util
import
lodtensor_to_ndarray
from
data_utils.util
import
split_infer_result
def
parse_args
():
...
...
@@ -58,13 +59,6 @@ def print_arguments(args):
print
(
'------------------------------------------------'
)
def
split_infer_result
(
infer_seq
,
lod
):
infer_batch
=
[]
for
i
in
xrange
(
0
,
len
(
lod
[
0
])
-
1
):
infer_batch
.
append
(
infer_seq
[
lod
[
0
][
i
]:
lod
[
0
][
i
+
1
]])
return
infer_batch
def
infer
(
args
):
""" Gets one batch of feature data and predicts labels for each sample.
"""
...
...
fluid/DeepASR/infer_by_ckpt.py
浏览文件 @
454de6ce
...
...
@@ -13,8 +13,10 @@ import data_utils.augmentor.trans_mean_variance_norm as trans_mean_variance_norm
import
data_utils.augmentor.trans_add_delta
as
trans_add_delta
import
data_utils.augmentor.trans_splice
as
trans_splice
import
data_utils.async_data_reader
as
reader
import
decoder.decoder
as
decoder
from
data_utils.util
import
lodtensor_to_ndarray
from
model_utils.model
import
stacked_lstmp_model
from
data_utils.util
import
split_infer_result
def
parse_args
():
...
...
@@ -141,13 +143,20 @@ def infer_from_ckpt(args):
infer_data_reader
.
recycle
(
features
,
labels
,
lod
)
cost
,
acc
=
exe
.
run
(
infer_program
,
feed
=
{
"feature"
:
feature_t
,
"label"
:
label_t
},
fetch_list
=
[
avg_cost
,
accuracy
],
return_numpy
=
False
)
infer_costs
.
append
(
lodtensor_to_ndarray
(
cost
)[
0
])
infer_accs
.
append
(
lodtensor_to_ndarray
(
acc
)[
0
])
results
=
exe
.
run
(
infer_program
,
feed
=
{
"feature"
:
feature_t
,
"label"
:
label_t
},
fetch_list
=
[
prediction
,
avg_cost
,
accuracy
],
return_numpy
=
False
)
infer_costs
.
append
(
lodtensor_to_ndarray
(
results
[
1
])[
0
])
infer_accs
.
append
(
lodtensor_to_ndarray
(
results
[
2
])[
0
])
probs
,
lod
=
lodtensor_to_ndarray
(
results
[
0
])
infer_batch
=
split_infer_result
(
probs
,
lod
)
for
index
,
sample
in
enumerate
(
infer_batch
):
print
(
"Decoding %d: "
%
(
batch_id
*
args
.
batch_size
+
index
),
decoder
.
decode
(
sample
))
print
(
np
.
mean
(
infer_costs
),
np
.
mean
(
infer_accs
))
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录